Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 6: Provide the output to console var x = \"good morning!\"; var f1 = fun

ID: 3737130 • Letter: P

Question

Problem 6:

Provide the output to console

var x = "good morning!";

var f1 = function() {

x = "good afternoon";

};

f1();

console.log(x);

// What is outputted to console?

var f2 = function() {

var x = "good evening";

};

f2();

console.log(x);

// What is outputted to console?

Submit Answer

Problem 7:

Write the JavaScript to declare a variable called breakfast and initialize it with the data the user enters in response to a prompt that asks the user "What would you like for breakfast?"

Submit Answer

Problem 8:

Write a JavaScript function that displays in a dialog box the data type of the variable x, where x is passed to the function as a parameter.

Submit Answer

Explanation / Answer

Problem 6: Provide the output to console var x = "good morning!"; var f1 = function() { x = "good afternoon"; }; f1(); console.log(x); // What is outputted to console? var f2 = function() { var x = "good evening"; }; f2(); console.log(x); // What is outputted to console? Answer : good afternoon good afternoon Problem 7: Write the JavaScript to declare a variable called breakfast and initialize it with the data the user enters in response to a prompt that asks the user "What would you like for breakfast?" Answer : var breakfast = prompt("What would you like for breakfast?"); Problem 8: Write a JavaScript function that displays in a dialog box the data type of the variable x, where x is passed to the function as a parameter. Answer : function dataType(x) { alert(typeof x); }