0
0
Javascriptprogramming~10 mins

Function 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 define a function named greet.

Javascript
function [1]() {
  console.log('Hello!');
}
Drag options to blanks, or click blank then click option'
Ahello
BsayHello
Cgreet
Dgreeting
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different function name than 'greet'.
Forgetting to name the function.
2fill in blank
medium

Complete the code to call the function greet.

Javascript
[1]();
Drag options to blanks, or click blank then click option'
Agreet
BsayHello
Chello
Dgreeting
Attempts:
3 left
💡 Hint
Common Mistakes
Calling a function name that was not defined.
Forgetting the parentheses when calling the function.
3fill in blank
hard

Fix the error in the function to correctly log the parameter.

Javascript
function greet(name) {
  console.log([1]);
}
greet('Alice');
Drag options to blanks, or click blank then click option'
AName
Bname
C'name'
Dgreet
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase 'Name' instead of 'name'.
Logging the string 'name' instead of the variable.
4fill in blank
hard

Fill both blanks to create a function that returns the sum of two numbers.

Javascript
function add([1], [2]) {
  return a + b;
}
Drag options to blanks, or click blank then click option'
Aa
Bb
Cx
Dy
Attempts:
3 left
💡 Hint
Common Mistakes
Using parameter names that don't match the return statement.
Using unrelated variable names.
5fill in blank
hard

Fill all three blanks to create a function that checks if a number is positive.

Javascript
function isPositive([1]) {
  if (num [2] 0) {
    return [3];
  } else {
    return false;
  }
}
Drag options to blanks, or click blank then click option'
Anum
B>
Ctrue
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different parameter name than 'num'.
Using '<' instead of '>' in the condition.
Returning false instead of true when the condition is met.