Script Valley
JavaScript Tutorial for Beginners to Advanced
Control Flow and Functions/Assessment

Practice & Assessment

Test your understanding of Control Flow and Functions

Multiple Choice Questions

5
1

Which of the following values is falsy in JavaScript?

2

What is the output of the following code? for (let i = 0; i < 3; i++) { console.log(i); }

3

What is the key difference between a regular function and an arrow function regarding 'this'?

4

What is a closure in JavaScript?

5

Which loop always executes its body at least once?

Coding Challenges

1
1

FizzBuzz with Functions

Write a JavaScript function called fizzBuzz(n) that loops from 1 to n. For multiples of 3, log 'Fizz'. For multiples of 5, log 'Buzz'. For multiples of both, log 'FizzBuzz'. Otherwise log the number. Call the function with n = 30.

Easy
GeeksForGeeks

Mini Project

1

Number Guessing Game

Build a number guessing game in the browser. Generate a random number between 1 and 100 using Math.random(). Prompt the user for guesses using a while loop and window.prompt(). After each guess, tell the user if the number is too high, too low, or correct. Count the number of attempts. When the user guesses correctly, display a congratulations message with the attempt count. Use functions for generating the number, checking the guess, and displaying feedback.

Medium