Module 05: Intro to Node.js

This exercise was an introduction to using node.js. We created three versions of one application that displays a message in the console log.

M05_1.js

This is a simple application that outputs a phrase depending on what variable is passed through the function.


    const $mess1 = 'These are words. Some more words.';
    const $mess2 = 'This is a phrase. A very short sentence. A slightly kind of maybe long sentence.';

    const $parag = ($part) => {
        console.log(`This is a paragraph made of different stuff. ${$part}`);
    }

    $parag($mess1);
    

We start with setting up two variables with different strings assigned. Then we set up a function that outputs the sentence “This is a paragraph made of different stuff.” plus one of the variables we set up earlier. After the function is setup, we call it, passing one of the variables of our choice.

In the command prompt, we run the file. If we pass $mess1 then it will output the following message.

    >node M05_1
    This is a paragraph made of different stuff. These are words. Some more words.

M05_2.js

Blah blah blah blah. This is an intro about the app. I sound super smart.


    const $mess1 = 'These are words. Some more words.';
    const $mess2 = 'This is a phrase. A very short sentence. A slightly kind of maybe long sentence.';
    const $messages = [$mess1, $mess2];
    var $states = 1;

    const $parag = ($part) => {
        console.log(`This is a paragraph made of different stuff. ${$part}`);
        }

    //$parag($mess1);

    let i = 0;
    while (i <= 1) {
        $parag($messages[i]);
        $states++;
        i++;
    }

    const $rating = ($states > 2) ? 'There are a lot of statements here.' : 'This is a fairly short statement.';
    console.log($rating);

I wrote an awesome explanation. Even someone with no coding background could understand. Blah blah blah blah. Blah blah blah blah blah blah. I go on and on about the code. It's just the best explanation.

FreeWebToolKit has a tutotial on how to display code snippets with color.