In this assignment you will demonstrate your ability to write functions and use unit tests. (As this is your first assignment focusing on unit testing, the unit tests will be supplied to you; in the future, you will need to gain experience and practice writing your own tests.)
Do the readings, watch the videos, write the essays, and program the applications below.
Submit, via Brightspace, the following:
Just read and/or watch the following. You do not have to take notes or write reports on them; however, don’t cheat yourself by skipping them. These independent learning units must be done individually, but please feel free to discuss these items with your friends and classmates. You are encouraged to share your thoughts on these materials on course community channels (Brightspace Forums, Slack, Discord), and to post related items your classmates might be interested in. We learn together. Some of these resources have links to other resources, which you may wish to follow as time allows.
This assignment is your chance to practice, practice, practice with functions and classes in JavaScript. And good news: unit tests are already written for you. Begin by forking (duplicating, remixing, copying, whatever your preferred word is) my starter code. Then, implement all the functions until all the unit tests pass. That’s all there is to it.
For reference, a brief description of the functions and classes you are to write follows. Note that specific details of the functions that are hard to capture in text are essentially captured in the unit tests! Remember that in a real sense unit tests are a form of documentation. The unit tests will tell you how to handle certain “invalid arguments” (throw an error? return undefined? ignore?) and what exactly to return.
"I know, right?"
the function should return "ikr"
. Every word gets to participate in the acronym. Even small ones, like “a,” “in,” and “of.” Words are separated by things that JavaScript thinks are spaces; therefore, to split your sentence, use the incantation sentence.split(/\s+/)
.typeof NaN === 'number'
, we don’t want NaNs here.map
, filter
, and reduce
. The body of your function must be a single expression.makeSequenceGenerator
that, when given a function and an initial value, returns a function that delivers values from a sequence each time it is called. For example, makeSequenceGenerator(x => x * 2 + 3, 2)
should return a function f
such that the first time you call f()
you get back 2, the second time you get back 2*2+3, or 7, and the next time 17, then 37, then 77, and so on.You will earn 5 points for each of problems 1-4 that pass all tests, and 10 points for each of problems 5-12 that pass all tests. Then as a measure of code quality, I will deduct 5-10 points for each violation of style, e.g. poor formatting, unconventional spacing and indentation, poor variable names, lack of breaking up complex subexpressions, mixing of concerns, and so on.