0
0
Javascriptprogramming~10 mins

Global execution context in Javascript - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a global variable named message with the value 'Hello'.

Javascript
var [1] = 'Hello';
Drag options to blanks, or click blank then click option'
Amsg
Bmessage
Cgreeting
Dtext
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different variable name than 'message'.
Forgetting to declare the variable with var, let, or const.
2fill in blank
medium

Complete the code to log the global variable message to the console.

Javascript
console.log([1]);
Drag options to blanks, or click blank then click option'
Amessage
B'message'
Cconsole
Dlog
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around the variable name, which prints the name as a string.
Using console or log alone inside console.log().
3fill in blank
hard

Fix the error in the code to correctly declare a global constant named PI with value 3.14.

Javascript
const [1] = 3.14;
Drag options to blanks, or click blank then click option'
Api
BPi
CpI
DPI
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or mixed case names like 'pi' or 'Pi' which are different variables.
Forgetting that JavaScript variable names are case-sensitive.
4fill in blank
hard

Fill both blanks to create a global object user with properties name and age.

Javascript
const user = { name: '[1]', age: [2] };
Drag options to blanks, or click blank then click option'
AAlice
B30
CBob
D25
Attempts:
3 left
💡 Hint
Common Mistakes
Using numbers as strings for age.
Mixing up the name and age values.
5fill in blank
hard

Fill all three blanks to create a global function greet that returns a greeting with the given name.

Javascript
function [1]([2]) {
  return `Hello, [3]!`;
}
Drag options to blanks, or click blank then click option'
Agreet
Bname
C${name}
Duser
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect function or parameter names.
Not using template literals properly for string interpolation.