Console log understanding

#1
let output = "Hello World";
let counter = 0;
welcome(output);
welcome(output);
welcome(output);

function welcome(para) {
    counter++;
    let temp = counter + " times run";
    console.log(para);
    console.log(temp);
}

In the above small JS function why is this line console.log(para); so important, and w/o this line console.log(temp); is also not publishing anything.

#2

Hi @codeispoetry, could you post the code where temp wouldn’t get logged? There must be another error, the previous log shouldn’t have anything to do with it.

BTW you can actually pass multiple arguments, like console.log(para, temp).

1 Like