top of page
JS02 - Program Structure
There are 7 short exercises you should complete to better understand Program Structure.
Be sure to review and consult the following lessons to complete this assignment:
Professor Debugsworth
I have created a custom GPT that you can use to complete the homework. It is an interactive coding tutorial that can help explain concepts to you in more detail.
Setup and Deliverable
Create an HTML page and a blank JS page.
Call the JS page exercise2.js
Be sure to use the script tag to link to the exercise2.js file. All of your testing will be done through console.log( ) statements, which you can preview on your html document.
Exercise 1 - Creating Bindings
// INSTRUCTIONS: Create bindings for:
// 1. Your age
// 2. Your birth year
// 3. The current year
// Then calculate and store in new bindings:
// 4. Your age in days (approximate)
// 5. The number of years until you reach 100
// Add comments explaining each calculationExercise 2 - Math functions
// INSTRUCTIONS: Use console.log to:
// 1. Show the result of a math calculation
// 2. Show multiple values in one log statement
// 3. Show a template literal using your bindings
// 4. Use Math.max and Math.min with 3 numbers you create
// 5. Create and log a calculation that results in NaN
// Add comments explaining what you expect each output to beExercise 3 - If Conditional Statements
// GIVEN VALUE:
let userNumber = 7;
// INSTRUCTIONS: Write if statements to:
// 1. Check if the number is positive
// 2. Check if the number is even or odd
// 3. Check if the number is between 1 and 10
// 4. Check if the number is divisible by both 2 and 3
// Create your own value and write a complex if/else statement that:
// 5. Uses at least 3 conditions with else if
// 6. Uses logical operators (&& or ||)Exercise 4 - Loops
// INSTRUCTIONS: Write loops that:
// 1. Count from 1 to 10 using a while loop
// 2. Count from 10 to 1 using a for loop
// 3. Output only even numbers from 2 to 20
// 4. Create a multiplication table for a number you choose
// Add comments explaining how each loop worksExercise 5 - More Loops
// INSTRUCTIONS:
// 1. Write a loop that finds the first number above 100 that's divisible by 7
// 2. Create a loop that keeps asking for input until a valid number is entered
// 3. Write a loop that calculates factorial of a number you choose
// 4. Create a loop that builds a string pattern of your choice
// Use comments to explain your logicExercise 6 - Guessing Game
// FINAL CHALLENGE: Create a number guessing game
// Requirements:
// 1. Generate a random number (use: Math.floor(Math.random() * 100))
// 2. Give the user 5 tries to guess the number
// 3. Tell them if their guess is too high or too low
// 4. Congratulate them if they win
// 5. Tell them the answer if they lose
// Break this down into steps and comment your logicLocked Message
bottom of page
