Javascript – Angular Picker 8

I use angle 8 when I choose a date and accept that the current date will be sent instead of the selected date. In all cases, the current date is used and not the selected date.
In HTML I have the following:


In the .ts file I have the following:
maxDate: Date = new Date ();

ngOnInit() {
this.form = new FormGroup({
'fecha': new FormControl(new Date()),

To send the date I have the following:

operar() {
let book = new Book();
var tzoffset = (this.form.value('fecha')).getTimezoneOffset() * 60000;
var localISOTime = (new Date( - tzoffset)).toISOString()
book.fecha = localISOTime;

Although you select the date of the previous day or a date on which you are working (), send the current date. What would be the mistake?

javascript – How can you wait for Ajax to return a response to continue the rest of the code?

I have a question and it is that I make a check in the database, whether a user or an e-mail has already been registered. Therefore, this review is done via ajaxbut at the same time it is also valid that the other fields are filled in correctly, the thing is that when I send in the request ajaxSince he has gone through the method and has already received the answer to the request, he has already gone through the entire method, so he does not consider it a mistake. I have already attached the code to clarify something:

AJAX method

function verificar(valor, opcion){
        var url = "/Jomar/inventario_dotacion/controllers/UsuarioController.php?action="; 
            case "1":
                url += "verificarUsu";
                var datos = {
                    "usuario" : valor
            case "2": 
                url += "verificarCorreo";
                var datos = {
                    "correo" : valor

            url: url,
            data: datos,
            type: "post",
            success: function(response){
                if(response.trim() == "1"){
                    return true;
                    return false;


Method for validation of fields

function validarCampos(){
        var nombres = document.forms("formRegistro")("nombres").value.trim();
        var apellidos = document.forms("formRegistro")("apellidos").value.trim();
        var correo = document.forms("formRegistro")("correo").value.trim();
        var usuario = document.forms("formRegistro")("usuario").value.trim();
        var clave = document.forms("formRegistro")("clave").value;
        var confirmClave = document.forms("formRegistro")("confirmClave").value;        

        var msg = "
    "; var formOk = true; if(nombres == ""){ msg += "
  • Nombres no puede ir vacío
  • "; formOk = false; } if(apellidos == ""){ msg += "
  • Apellidos no puede ir vacío
  • "; formOk = false; } if(correo == ""){ msg += "
  • Correo no puede ir vacío
  • "; formOk = false; }else{ if(correo.indexOf('@') == -1){ msg += "
  • El correo debe tener @
  • "; formOk = false; } var respuesta; if(correo.indexOf('.') == -1){ msg += "
  • El correo debe tener "."
  • "; formOk = false; }else{ respuesta = verificar(correo, "2"); if(respuesta){ msg += "
  • Correo ya existente
  • "; formOk = false; } } } if(usuario == ""){ msg += "
  • Usuario no puede ir vacío
  • "; formOk = false; }else{ respuesta = verificar(usuario, "1"); if(respuesta){ msg += "
  • Usuario ya existente
  • "; formOk = false; } } if(clave == ""){ msg += "
  • Clave no puede ir vacío
  • "; formOk = false; } if(confirmClave == "" && clave != ""){ msg += "
  • Tienes que confirmar Clave
  • "; formOk = false; }else if(clave != confirmClave){ msg += "
  • Claves no coinciden
  • " ; formOk = false; } msg += "
" if(!formOk){ $("#errores").html(msg); $("#errores").fadeIn("slow"); } return formOk; }

I hope it is understandable, when in doubt, the question is how to validate this field ajax and not go through the method without getting an answer, or how can you do it differently?

Javascript – Approve / reject a workflow with comments on the client side

I have a list associated with a "SharePoint 2010 Approval Workflow" and I want to allow the use of simple buttons to approve / reject the workflow after startup. I did that from JavaScript with the following code:

var context = SP.ClientContext.get_current();
var list = context.get_web().get_lists().getByTitle("Approval Tasks");
var item = list.getItemById(taskId);
item.set_item("WorkflowOutcome", "Rejected");
item.set_item("Status", "Rejected");
item.set_item("FormData", "Completed");
item.set_item("PercentComplete", 1);
item.set_item("Completed", true);
    function(sender, args) {
    function(sender, args) {

The problem I'm facing right now is that I do not seem to find a way to programmatically write in the Comments field. This field will be displayed on the Approval / Reject form. It would be very useful if the user could provide a description of the rejection there using my custom buttons. I do not seem to understand where this information is stored.

I'll attach a picture to the workflow form so you can better understand what I'm talking about (I've dimmed sensitive data and highlighted the box with a red rectangle).

Thank you for your support.

Workflow Form


I try to extend the functionality or not a box. The remove button works normally, but the reduce button does not. I can see that clicking the button triggers an event in the DOM, but for some reason the box does not respond as expected.



Area Chart

That's the code. And these are the dependencies that are loaded into the application:

import 'modules/admin-lte/plugins/jQueryUI/jquery-ui.min'
import 'modules/admin-lte/plugins/jQuery/jquery-2.2.3.min'
import 'modules/admin-lte/dist/js/app.min'
import 'modules/admin-lte/bootstrap/js/bootstrap.min'
import 'modules/admin-lte/plugins/fastclick/fastclick'
import 'modules/admin-lte/plugins/slimScroll/jquery.slimscroll.min'

import 'modules/font-awesome/css/font-awesome.min.css'
import 'modules/ionicons/dist/css/ionicons.min.css'
import 'modules/admin-lte/bootstrap/css/bootstrap.min.css'
import 'modules/admin-lte/dist/css/AdminLTE.min.css'
import 'modules/admin-lte/dist/css/skins/_all-skins.min.css'
import 'modules/admin-lte/plugins/iCheck/flat/blue.css'

import './custom.css'

Javascript code that works differently in different environments

I learned for an upcoming exam and found something strange.
Here is the prompt for the question:

They have a fashion catalog, a collection of articles from various high-fashion designers. Every designer has a number of shoes. Every shoe has a name and a price.

It looks like this:

 var currentInventory = (
    name: 'Brunello Cucinelli',
    shoes: (
      {name: 'tasselled black low-top lace-up', price: 1000},
      {name: 'tasselled green low-top lace-up', price: 1100},
      {name: 'plain beige suede moccasin', price: 950},
      {name: 'plain olive suede moccasin', price: 1050}
    name: 'Gucci',
    shoes: (
      {name: 'red leather laced sneakers', price: 800},
      {name: 'black leather laced sneakers', price: 900}

Your function should return the average cost of all shoes per designer in this format:

var expected = {
  'designers': (
      'name': 'Brunello Cucinelli',
      'averagePrice': 1025
      'name': 'Gucci',
      'averagePrice': 850

I've written code and it behaves differently, whether I'm running it on or the Hack Reactor Lab site. Here is my code:

function calculateAveragePricePerDesigner(inventory) {
  var result = {designers: ()};
  var parsedDesignerAverageCost = ();
  for (i = 0; i < inventory.length; i++) {
  result.designers = parsedDesignerAverageCost;
  return result;

function parseAverageCostPerDesigner(currentDesigner) {
  var currentShoes =;
  var result = {
    averagePrice: 0
  var cummulativeCost = 0;
  var numOfShoes = currentShoes.length;
  for (i = 0; i < numOfShoes; i++) {
    cummulativeCost +=;

  var average = cummulativeCost / numOfShoes;
  result.averagePrice = average;
  return result;

Can someone explain if my code is correct or not and possibly why the inconsistency occurs? My code is compiled on but not executed in a way I can not explain, and it is not compiled on the Hack Reactor site.
Many thanks

Javascript – SharePoint 2016 webAbsoluteUrl error

When trying to implement the following code in SharePoint 2016, the following error appears: The property & # 39; webAbsoluteUrl & # 39; can not be retrieved with undefined or null reference

The developer tool points to this line var absoluteURL = _spPageContextInfo.webAbsoluteUrl;

        function getData(lName){
        var absoluteURL = _spPageContextInfo.webAbsoluteUrl;
        if(lName == "Navigation"){
            var endPointUrl = absoluteURL + "/_api/web/lists/getbyTitle('"+lName+"')/items";
            var endPointUrl = absoluteURL + "/_api/web/lists/getbyTitle('"+lName+"')/items?$select=parentNav/URL, parentNav/URLNAME,subLink&$expand=parentNav";

Javascript – jQuery does not work for me

Hello good

You see, I start in jQuery and do not know why the following code does not work for me.


Introduction to jQuery

JQuery official site:

In my folder I have the appropriate jQuery file, as I show in the photo below.

Enter image description here

Greetings and thank you!