Skip to content

cs-fullstack-master/javascript-loops-timers-cw

Repository files navigation

JavaScript Loops and Timer Events - Classwork

Find the Largest Number in the Array

Write a JavaScript conditional statement to find the largest of the five numbers from the array below. Use an alert box to show the result.

const myNumberList = [12, 2112, 9000, 1999, 24];

Exercise 1: While/For Loops

  • Create an empty name_array
  • Ask the user Enter a word. Enter 'q' to quit. Add each word they enter to the array
  • Create a while loop that will keep asking for words to add to the array until they enter 'q'
  • When the user enters 'q' use a for loop to print each word from the array
  • NOTE: Your code should handle the case of the entered quite letter Q

Exercise 2: Loops - FIZZBUZZ

FIZZBUZZ is a classic Programmer's challenge often used as part of job interviews.

User inputs the ending value (e.g. 100)

Your code should start at 1 and then iterate each number up to the maximum

  • If the current number is evenly divisible by 3 you should print "FIZZ" and the number
  • If the current number is evenly divisible by 5 you should print "BUZZ" and the number
  • If the current number is evenly divisible by both 3 and 5 you should print "FIZZBUZZ" and the number
  • Otherwise, just print the number to the console

Timer Challenge 1:

Animate the included sprite images of 'guy' images. Start with an initial image of guy1.png then every .5 second (500 ms) update the image to the next one in sequence. Once you reach image guy9.png start over with the guy1.png image.

SUPER MARIO Challenge 2:

Animate Mario walking to the left and right by pressing the left and right arrow keys (HINT: implement event handler(s) for handling the key presses)

About

JavaScript Loops and Timer Events

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published