JS Code Samples

JS Code Samples

by lshettyl

JavaScript

// 2nd biggest number from an array;

// add/minus calculator using angular

// Roll the dice

var link = function (height, color, url) {
    var height = height || 50;
    var color = color || 'red';
    var url = url || 'https://www.google.com';
}

//Delete multiple posts, array of ids, wait for completion

for (var i = 1; i < 10; i++) {
	setTimeout(function(){
  	console.log(i);
  }, 100)
}

var a1 = [10,20,30,40];
var a2 = ["some", "one", "is", "watching"];
console.log ( [...a1, ...a2] )
//concat()

(function() {

	fn1();
  
  fn2();
  
  console.log(myVar1);
  
  console.log(myVar2);

	function fn1() {
  	console.log("I am fn1");
  }

	var fn2 = function() {
  	console.log("I am fn2");
  }
  
  var myVar1 = "I am myVar1";
  
  let myVar2 = "I am myVar2";

	fn2();
}());