var msg = "Hello, World!";

function logIt(output) {
    console.log(output);
}
logIt(msg);

console.log("Reuse of logIT")
logIt("Hello, Students!");
logIt(2022)
Failed to start the Kernel. 

View Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details.

Loosely Typed Language Demonstration

function logItType(output) {
    console.log(typeof output, ";", output);
}
console.log("Looking at dynamic nature of types in JavaScript")
logItType("hello"); // String
logItType(2020);    // Number
logItType([1, 2, 3]);  // Object is generic for this Array, which similar to Python List
Failed to start the Kernel. 

View Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details.

Timer

$$.async();

console.log("Hello, World!");

var action = {
    $$: $$,
    console: console,
};

setTimeout(function() {
    $$.clear(0);    // clear output cell
    action.$$.sendResult("Goodbye!");
}, 2000);  // 2 second timer
Failed to start the Kernel. 

View Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details.

Colors Hack

const resultContainer = document.getElementById("result");

   // function holds data for colors
    function Color(name, emotion, symbolism) {
        this.name = name;
        this.emotion = emotion;
        this.symbolism = symbolism;
    }

    // json conversion function
    Color.prototype.toJSON = function() {
        const obj = {name: this.name, emotion: this.emotion, symbolism: this.symbolism};
        const json = JSON.stringify(obj);
        return json;
    }

    // list of colors
    var list = [ 
        new Color( "Red", ":)", "life, health, vigor"),
        new Color( "Orange", ":)", "fun, strength, courage"),
        new Color( "Yellow", ":)", "happiness, warmth, sunshine"),
        new Color( "Green", ":|", "nature, wisdom"),
        new Color( "Blue", ":(", "calmness, despair"),
        new Color( "Indigo", ":(", "communication, peace"),
        new Color( "Violet", ":(", "higher self, comprehension")
    ];

    function ColorClass(colors){
        this.ColorClass = colors;
        this.json = [];
        this.ColorClass.forEach(colors => this.json.push(colors.toJSON()));
    }

    // creates colorlist object
    colorlist = new ColorClass(list);

// javascript variables and methods to build html using previous data

    for (const row of colorlist.ColorClass) {

        const tr = document.createElement("tr");

        const name = document.createElement("td");
        const emotion = document.createElement("td");
        const symbolism = document.createElement("td");

        name.innerHTML = row.name;
        emotion.innerHTML = row.emotion; 
        symbolism.innerHTML = row.symbolism; 


        tr.appendChild(symbolism);
        tr.appendChild(name);
        tr.appendChild(emotion);


        resultContainer.appendChild(tr);
    }
Failed to start the Kernel. 

View Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details.