- Understanding conditional statements and their role in programming.
- Exploring the
ifstatement and its syntax. - Using comparison operators (
==,!=,>,<,>=,<=) to create conditions. - Understanding the
else ifandelsestatements for handling multiple conditions.
- Understanding looping statements and their role in repeating actions.
- Exploring the
forloop and its syntax. - Using the
forloop to iterate over a range of values. - Exploring the
whileloop and its syntax. - Understanding the
do-whileloop and its differences from thewhileloop.
-
Print even numbers:
- Write a program that prints all even numbers from 1 to 20.
- Use a looping statement to iterate over the numbers.
- Check if each number is even using a conditional statement.
- Print the even numbers to the console.
-
Temperature conversion:
- Write a program that converts temperatures from Celsius to Fahrenheit.
- Prompt the user for a temperature in Celsius.
- Use a conditional statement to check if the input is valid.
- If valid, convert the temperature to Fahrenheit using the formula:
F = (C * 9/5) + 32. - Print the converted temperature to the console.
-
Find the maximum number:
- Write a program that finds the maximum number from a given array of numbers.
- Use a loop to iterate over the array elements.
- Keep track of the maximum number encountered so far using a variable.
- After the loop, print the maximum number to the console.
Estimated time to complete this module is approximately 4-6 hours.
To further enhance your learning, here are some additional resources:
- MDN Web Docs on Control Structures: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Control_flow_and_error_handling
- JavaScript.info on Conditional Operators: https://javascript.info/ifelse
- JavaScript.info on Loops: https://javascript.info/while-for
- FreeCodeCamp's JavaScript Loops and Conditional Statements: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript