Click to reopen instructions.

This assessment consists of functions you need to write involving numeric, boolean, and string expressions as well as some use of control constructs. It is a closed book assessment. You should stay on this tab until you are done and there should be no talking. This assessment is about how much you understand. There are no automatic tests but you can use the REPL to test things yourself.

You can move through the questions with the arrows at the upper right next to the 1 of indicator so if you're not sure how to write one function move on to another one and come back if you have time at the end. I want to see how much you do know. Note: you can also click on thingsLikeThis in these instructions and the questions to copy them to the clipboard to avoid spelling mistakes.

Some functions that you may find useful are Math.abs, Math.floor, and Math.sqrt which all take a single numeric argument and return, respectively, the absolute value of the argument, the nearest integer less than the argument, and the square root of the argument. Also useful is Math.min which takes any number of arguments and returns the minimum value, e.g. Math.min(33, 44) returns 33.

When you are done, please submit a GitHub pull request of the branch and request me as a reviewer. Doing this correctly is part of the assessment.

Put definitions here.

Revisions:

Questions of

Write a function named averageWeight that takes two arguments, the total weight of a number of items and the number of items, and returns the average weight of an item. E.g. if the total weight is 1,000 and there are 20 items, the average weight is 50.

Write a function named hypotenuse that takes two arguments representing the lengths of the two legs of a right triangle and returns the length of the hypotenuse. Recall the Pythagorean theorem that tells us that c2 = a2 + b2 where a and b are the lengths of the two legs of a right triangle and c is the length of the hypotenuse.

Write a function named maxRadius that takes two arguments, the first being the width and the second being the height of a drawing area. It should return the radius of the largest circle that can be drawn in the drawing area.

Write a function named numCircles that takes two arguments, the radius of a circle and the width of a drawing area, and returns the largest integer number of non-overlapping circles of the given radius that can be drawn in a line across the drawing area..

Write a function named offset that takes two arguments, the width, in pixels, of a drawing area and the width of a figure (guaranteed to be less than the total width, also in pixels) and which returns the number of pixels from the left side of the drawing to shift the figure to be horizontally centered in the drawing area.

Write a function named canSleepIn that takes two boolean arguments, the first saying whether it's a weekday and the second saying whether you're on vacation, and returns true if you are allowed to sleep in and false otherwise. The rules are you can always sleep in when you're on vacation and you can also sleep in on weekends.

Write a function named canGoToProm which takes three boolean arguments describing a person. The first specifies if they are a senior, the second specifies if they were invited to prom by a senior, and the third specifies if they are on the prom exclusion list. The function should return a boolean indicating whether or not the person is eligible to go to prom. The rules are seniors and people invited by seniors are eligible unless they are on the exclusion list.

Write a function named getsSpeedingTicket that takes two arguments, a number indicating the speed in miles per hour that you were driving and a boolean indicating whether the cop who pulled you over is grouchy. Return a boolean value indicating whether you will get a ticket given that a grouchy cop will give you a ticket if you are going over 65 while a non-grouchy cop will only give you a ticket if you're going over 70 mph.

Write a function named moreThanTwiceAsLong that takes two string arguments and returns a boolean indicating whether the first string contains more than twice as many characters as the second string.

Write a function named aFartherThanB that takes three arguments, all numbers and returns a boolean indicating whether the first argument is farther away (on the number line) from the third argument than the second argument. I.e. if we call the arguments a, b, and c, return true if a is farther away from c than b is.

Write a function named firstHalf that takes a single string argument and returns the first half of the string. (If the string has an odd number of characters it doesn't matter whether or not you include the extra character.) For instance the first half of 'foobar' is 'foo' but if the argument was 'fooquux' then either 'foo' or 'fooq' would be acceptable return values.

Write a function named secondHalf that takes a single string argument and returns the second half of the string. (If the string has an odd number of characters it doesn't matter whether or not you include the extra character.) For instance the second half of 'foobar' is 'bar' but if the argument was 'fooquux' then either 'quux' or 'uux' would be acceptable return values. For maximum style points write this function and firstHalf so that firstHalf(s) + secondHalf(s) gives you back s.

Write a function named upDown that takes a single string argument and returns a string consisting of the original string all in upper case concatenated (“smooshed together”) with the string all in lower case. E.g. called with 'foo' it should return 'FOOfoo'.

Write a function named everyOther that takes a single string argument that is at least five characters long and returns a string consisting of just the first, third, and fifth characters of the argument string. E.g. called with 'foobar' it should return 'foa'.

Write a function named upDownLastCharacter that takes a single string argument that is at least one character long and returns a string consisting of two characters, the uppercase version of the last character of the argument string and the lowercase version of that same character. E.g. called with 'foo' it should return 'Oo'.

Write a function named yesIfEven that takes a single argument which will be a number and returns the string 'yes' if the argument is even and 'no' otherwise.

Write a function named countXs that takes a single string argument and returns the number of 'x' characters that occur in the string.

Write a function named timesTable that takes a single number as its argument and emits a times table of all the products from 1 × 1 to n × n. Use the emit function defined in the starter code to actually emit the different values. It takes three arguments, the two numbers being multiplied and their product, and prints them out nicely; you just need to call it once for each pair of arguments. N.B. that order matters so, assuming you are emitting a times table that includes 2 × 3 you need to call both emit(2, 3, 6) and emit(3, 2, 6).

Write a function named containsX that takes a single string argument and returns a boolean that indicates whether the string contains any 'x' characters.

Write a function named sumSquares that takes a single number argument and returns the sum of the squares of all the positive integers less than the argument. For instance given the argument 4 it should return 14, i.e. 12 + 22 + 32, i.e. 1 + 4 + 9.

REPL