UNB/ CS/ David Bremner/ teaching/ cs2613/ labs/ CS2613 Lab 8

Background

Part 1: Running JavaScript

Time
20 minutes
Activity
Demo

In Code-OSS

    console.log("Hello world");

In a Browser

Note
Examples involving "prompt" and "alert" will only work in a browser.

Running a script

In the REPL

Part 2: Translating Racket expressions into Javascript

Time
25 minutes
Activity
Small groups, individuals
    //(string-append "Hello\n" "world!")

    //(* (+ 1 2 3) 7)

    //(< 41 (* 6 7))

    //(equal? (* (+ 1 2 3) 7) 42)

    //(equal? "Spongebob" "Squarepants")

    //(and (equal? (* 6 7) 42) (equal? "Spongebob" "Squarepants"))

    //(equal? 42 (if (< 3 5) (* 6 7) "turnip"))

    // (or #t (/ 1 0))

    // (and #f (/ 1 0))

Part 3: Looping

Time
20 minutes
Activity
Small groups, individuals
    #
    ##
    ###
    ####
    #####
    ######
    #######

Part 4: Some weird JavaScript expressions.

Time
10 minutes
Activity
Demo / Discussion

Part 5: FizzBuzz (if)

Time
20 minutes
Activity
Small groups, individuals

Solve the famous FizzBuzz problem in JavaScript.