To Lecture Notes

IT 238 -- Apr 13, 2026

Review Exercises

  1. Find the errors in the source code files contained in this project:
         meters-to-ft-in.zip.
  2. What are the four primitive JavaScript datatypes that we saw last week?
  3. Name two two non-primitive JavaScript datatypes?
  4. What is the JavaScript ** operator?
  5. How do the Math.floor, Math.ceil, and Math.round methods work? Look at the Some Math Methods section of the Mar 8 Notes to answer this question.
  6. How can you use Math.round to round a floating point number to three digits after the decimal point?
    Answer:
    var amount = 23.5425643;
    var amtRounded = Math.floor(amount * 1000) + 1;
    // Details of calculation
    // Original amount: 23.5425643;
    // Amount after multiplying by 1000: 23542.5643
    // Amount after taking the floor:    23542
    // Amount after dividing by 1000:    235.42
    
  7. Use the JavaScript Math.random method, which returns a floating point number in the interval [0, 1), to return a random number in the set {1, 2, 3, 4, 5, 6}.
    var randomValue = Math.floor(Math.random( ) * 6) + 1
    // JS Expression       Random Output Range
    // Math.random( )      [0, 1)
    // Math.random( ) * 6  [0, 6)
    // Math.floor(Math.random( ) * 6)     {0, 1, 2, 3, 4, 5}
    // Math.floor(Math.random( ) * 6) + 1 {1, 2, 3, 4, 5, 6}
    
  8. 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?
  9. This Road Runner cartoon shows two versions of the while loop.

  10.  Explain how a while loop is related to a traditional for loop.
  11. 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.

Expression Interpolation

Comparisons for Equality

Arrays

Properties and Methods

Truthiness

Scope

Project 2a