This assessment consists of functions you need to write involving numeric expressions. 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 10 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.
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.
Write a function named itemsLeftOver
that takes two
arguments, a number of people and a number of items, and returns the
number of items that will be left over after you give each person
the maximum number of items you can while giving everyone the same
number of items.
Write a function named areaOfCircle
that takes one
argument, the radius of a circle, and returns the area of the
circle. The formula for the area of a circle with radius r is
πr2. In Javascript you can
use Math.PI
to get a good approximation of π.
Write a function named volumeOfCube
that takes a single
argument specifying the length of one edge of a cube, and returns
the volume of the cube.
Write a function named populationGrowth
that takes two
numeric arguments, the current size of a population and a growth
rate expressed as a fraction the population will grow in a day. The
function should return the amount by which the population will grow
in one day. For example, if the population was initially 100 and the
growth rate was 0.25, it would grow by 25 members.
Write a function named earnedRunAverage
that takes two
arguments, the number of “earned runs” a baseball pitcher has given
up and the number of innings that pitcher has pitched. The function
should return the pitcher’s Earned Run Average (ERA) which is
defined as the average number of earned runs per inning pitched
multiplied by 9.
Write a function named valueOfJewels
that takes four
arguments, a number of diamonds, a number of emeralds, the value of
one diamond in gold pieces, and the value of one emerald in gold
pieces. The function should return the value in gold pieces of the
given number of diamonds and emeralds. In other words multiply the
number of each type of jewel by the value of that kind of jewel and
sum the products.
Write a function named payWithOvertime
that takes three
numeric arguments, a number of hours someone worked, their normal
hourly rate, and their overtime rate. The function should return how
much they are paid for the hours worked assuming that they are paid
their normal rate for the first eight hours and their overtime rate
for any hours beyond that.
Write a function named firstClassPostage
that takes one
argument, the weight in ounces of a letter. It should return the
postage needed, in cents, to mail the letter given that anything up
the first ounce costs 60 cents and each additional ounce, or
fractional ounce, costs 24 cents. A function that will be useful
is Math.ceil
which returns the smallest integer greater
than or equal to its single argument. For
instance, Math.ceil(2.3)
is 3.
Write a function named weightOnJupiter
that takes a
single argument, the weight of a person in kilograms on Earth, and
returns the weight of that same person on Jupiter.
Note that weights on other planets are computed by multiplying the
Earth weight by the ratio of the other planet’s gravity to Earth’s
gravity. For instance, if there was a planet whose gravity was
exactly twice Earth’s, then someone would weight exactly twice as
much on that planet as on Earth. Two useful constants defined in the
starter code for you are JUPITER_GRAVITY
and EARTH_GRAVITY
Write a function named gravity
that takes three numeric
arguments, the first two are the masses of two bodies (such as
planets) and the third is the distance between the two objects. It
should return the gravitational force attracting the two bodies
which is computed as the product of the bodies’ masses divided by
the square of the distance between them, all multiplied by the
universal gravitational constant which is defined for you in the
starter code as the constant G
.