lundi 18 novembre 2019

Javascript returns object in browser but nothing in VSCode

My code works in the browser by returning an object, however if I run this in VSCode or on in the terminal, I either get no output or a null output with no error. I'm trying to figure out how to get this to work on my machine, not just in the browser.

var residential = "residential";
var commercial = "commercial";
var check = "residential";

var make = function(site_type, value) {
  // Define desired object
  var obj = {
    site_type: site_type,
    check: value
  };
  // Return it
  return obj;
};

if (check == "residential") {
  var value = "residential";
  make(residential, value);
} else if (commercial == "null") {
  var value = "residential";
  make(residential, value);
} else {
  var value = "commercial";
  make(commercial, value);
};

Aucun commentaire:

Enregistrer un commentaire