Knowee
Questions
Features
Study Tools

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

Question

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

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

Solution

The output of this code will be 89.

Here's the step by step explanation:

  1. The constant b is declared and assigned the value 79.
  2. The function myFunction is called with the argument 10.
  3. Inside the function, a is 10 (the passed argument) and b is 79 (the global constant).
  4. The console.log(a + b); statement adds a and b together, which results in 89.
  5. This result (89) is then logged to the console.

This problem has been solved

Similar Questions

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?(function(){  setTimeout(()=> console.log(1),2000); console.log(2); setTimeout(()=> console.log(3),0); console.log(4); })();*1 2 3 42 3 4 14 3 2 12 4 3 1

What will the following JavaScript code output?(function() { var a = b = 5;})();console.log(b);5ReferenceError: b is not definednullundefined

6What will the code below output to the console and why?const obj = {a: 1,b: 2};const arr = [];console.log(arr[0] = { ...obj });Review Later1,2{…obj}{a: 1, b: 2}Does not compile

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

1/3

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.