Lecture 8

The Exam - solutions /  The Group project / The Canvas

b.socrative.com/login/student

Room name: JKOHLIN

slides.com/jkohlin/tkpk18-lecture-8

The Exam

function bpm(minutes,beats) {
 /* your code here */
}

Write a function called bpm that takes 2 numbers as arguments: the length of a song in minutes, and the amount of beats in the song, as input
and calculates and returns the correct Beats Per Minute

The Exam

function smallestNumber(arr) {
 /* your code here */
}

smallestNumber is a function that takes any array of numbers (0-9) as input and returns the smallest number from that array.

The Exam

function biggestNumber(num1, num2) {
 var msg = " is the biggest number";
 /* your code here */
}

Create a function that compares two numbers and returns a string that says "x is the biggest number", where x is the highest number passed to the function.

The Exam

function isValidWalk(directions) {
 /* your code here */
}

Create a function that will return true if the walk that the app gives you
will take you exactly ten minutes and will, of course, return you to your starting point. Return false otherwise.

isValidWalk(['n','s','e','w','n','n','n','s']) // false

isValidWalk(['n','s','e','w','n','n','n','s','s','s']) // true

Canvas #1

Lecture 8

By Johan Kohlin

Lecture 8

  • 658