Knowee
Questions
Features
Study Tools

What is the output of this code?const a = 12;function myFunction(a) { console.log(a);}myFunction(89);112289

Question

What is the output of this code?

const a = 12;
function myFunction(a) {
    console.log(a);
}
myFunction(89);

112289

🧐 Not the exact question you are looking for?Go ask a question

Solution

The output of the code will be 89.

Here's the step by step explanation:

  1. The constant a is declared and assigned the value 12.
  2. A function myFunction is declared, which takes one argument a. Inside this function, the value of a is logged to the console.
  3. The function myFunction is called with the argument 89.

When the function myFunction is called, the argument 89 is passed into the function. This value shadows the global constant a that was declared at the beginning. So, inside the function, a refers to the argument passed in, not the global constant. Therefore, 89 is logged to the console.

This problem has been solved

Similar Questions

What is the output of this code?function myFunction(a) { console.log(a + b);}const b = 79;myFunction(10);

What is the output of following code?var a = 10;function test() { a = 20;}test();console.log(a);Options: Pick one correct answer from below1020

What will be the output of the following code snippet?var a = 1; var b = 0;  while (a <= 3) {  a++;  b += a * 2;  print(b); }*4 10 181 2 3None of Above1 4 7

What will the below statements print on the console?"use strict"function abc() {console.log(this);}abc();

What would be logged to the console by the following block of code?let a = "ILoveProgramming"; let result = a.substring(3, 6);console.log(result);vePILogniing

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.