This assessment consists of functions you need to write. Five involve boolean expressions, five involve string expressions, and the last two a combination. 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 12 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.
The BHS fire alarms go off if a fire alarm is pulled, if smoke is
detected, or if there is a planned fire drill. Write a function
named fireAlarm
that takes three arguments and returns
a boolean value indicating whether the fire alarm should go off.
The values of the arguments will be booleans indicating, in order, whether a fire alarm was pulled, whether smoke was detected, and whether there is a planned fire drill.
There are three criteria for a person to be eligible to be elected president of the United States: they must be at least 35 years old, they must be a natural born citizen, and they must have lived in the US for at least fourteen years. A person must meet all these criteria to be eligible.
Write a function named canBePresident
that takes three
arguments, and returns true if a person can be president. The first
argument is the persons age in years; the second, a boolean
indicating whether or not they are a natural born citizen; and the
third, the number of years they’ve lived in the US.
On Twitter, a user should see a tweet if they follow the person who tweeted it or if they follow a person who retweeted it. However they should never see a tweet from someone they have blocked.
Write a function named willSeeTweet
that returns a
boolean indicating whether a user should see a given tweet according
to the values of it’s three boolean arguments. The first says
whether they follow the tweeter; the second, whether they follow
someone who retweeted the tweet; and the third, whether they have
blocked the original tweeter.
Write a function named evenGreaterThanZero
that takes a
single numeric argument and returns a boolean indicating whether the
number is an even number greater than zero.
The rules for leap years are more complex than you may know. The
basic rule is that all years evenly divisible by 4 (i.e. year
% 4 === 0
) are leap years. However, years evenly divisible by
100 are not leap years unless they are evenly
divisible by 400. Thus 2004 was a leap year by the normal rule but
2100 will not be because it’s divisible by 100. But 2000 was because
although it was divisible by 100 it was also divisible by 400.
Write a function named isLeapYear
that takes a single
argument of a year number and returns a boolean indicating whether
or not it is a leap year.
Write a function named firstAndLast
that takes a single
string argument (which will be at least two characters long) and
returns a string consisting of just the first and last characters of
the string.
Write a function named swapFrontAndBack
that takes a
single string argument and returns a string consisting of the second
half of the original string followed by the first half. If the
string is an odd number of characters it doesn’t matter whether the
extra character goes with the front or the back.
As you should recall from the Pig Latin assignment, the rules of simple Pig Latin say that a word is translated into Pig Latin by taking everything up to (but not including) the first vowel and moving it to the end of word and then adding “ay” to the end.
Write a function named simplePigLatin
that takes two
arguments, a string containing a single word and a number indicating
the index of the first vowel in the word, and returns the word
translated into Pig Latin.
Write a function named randomCharacter
that takes a
single string argument and returns a random character from the
string. For this function you will need to use the rand
function defined at the top of the starter code.
Write a function named randomCharacterUpDown
that takes
a single string argument and returns a string consisting of a single
random character repeated twice, once in upper case and then in
lower case. For this function you will need to use
the rand
function defined at the top of the starter
code.
Write a function named isAllUpperCase
that takes a
single string argument and returns a boolean indicating whether the
string is all upper case.
Write a function named sameIgnoringCase
that takes two
string arguments and returns a boolean indicating whether they are
the same string if you ignore case differences.