To Lecture Notes

IT 212 -- Apr 14, 2025

Review Exercises

  1. What is the ** operator?
  2. How do the Math.floor, Math.ceil, and Math.round methods work?
  3. How can you use Math.round to round a floating point number to three digits after the decimal point.

Control Structures

Practice Problems

  1. What were the control structures mentioned in Edsgar Dykstra's seminal letter Go To Considered Harmful sent to the editor of the journal of the Association of Computing Machinery (ACM) in 1968? Look at how traditional for loops work.
  2.  Explain how a while loop is related to a traditional for loop.
  3. Write a for loop that prints the integers 1 to 1,000 on a browser page. Put 20 numbers on each line. Hint: whenever n % 20 == 0 for a number, write "<br>".
  4. Using the document.write method, write a double for loop that writes the following to the browser document:
    *
    **
    ***
    ****
    *****
    ******
    *******
    
    Use a prompt box to enter the number of rows.
  5. This problem was given as part of a job interview programming test, according to the Eloquent JavaScript textbook. Write a loop that prints the numbers from 1 to 100. If a number is divisible by 3, print Fizz after it. If the number is divisible by 5, print Buzz after it. If the number is divisible by both 3 and 5, print Fizz Buzz after it. Here is the beginning of the output:
    1
    2
    3 Fizz
    4
    5 Buzz
    6 Fizz
    7
    8
    9 Fizz
    10 Buzz
    11
    12 Fizz
    13
    15 Fizz Buzz
    16
    17
    ...
    
  6. Write a function convert that inputs a length in meters then outputs the length feet and inches. Test your function like this:
    document.writeln(convert(1.0));
    // Output: 3'3"
    

Practice Quiz

Expression Interpolation

Comparisons for Equality

Arrays

Properties and Methods

Truthiness