stack overflow javascript code example

Example 1: how to add javascript in html stack overflow

$(document).ready(function() {
  // add your code here
})

Example 2: javascript function stack overflow

function firstFunction(){
  console.log("Hello from firstFunction");
}

function secondFunction(){
  firstFunction();
  console.log("The end from secondFunction");
}

secondFunction();

Example 3: stockoveslow javascript

function sum() {
    var retval = 0;
    for (var i = 0, len = arguments.length; i < len; ++i) {
        retval += arguments[i];
    }
    return retval;
}

sum(1, 2, 3) // returns 6