This exercise has been developed to give you an opportunity to work with JavaScript Objects, Arrays, Functions, Loops, and Events. There are separate sections for the various parts of the assignment, broken up into separate folders:
1-fizzbuzz: a program that counts from 1 to a given integer, printing out fizz if the number is divisble by 3, buzz if it is divisible by 5, and fizzbuzz if it is divisible by both 3 and 5.2-fizzbuzz-fun: an adaptation of the FizzBuzz algorithm but with a function.3-reverse-string: a program that takes a string as input and reverses it using JavaScript string methods.4-reverse-string-iterate: a program that takes a string as input and reverses it by iterating through the string, character by character.5-character-count: a program that takes a string as input and counts how many of each character are in that string.
This assignment uses the local module getargs to pull a single argument out of the command line for input and console.log(<string>) for all output.
Read more about these topics in the local file reference.md.
In order to complete this project successfully, you will need to fulfill these requirements:
- Complete the code for all of the associated TODOs in
index.jsin the1-fizzbuzzfolder such that the program accepts numeric input and correctly outputs fizz, buzz, or fizzbuzz for each number. - Complete the code for all of the associated TODOs in
index.jsin the2-fizzbuzz-funfolder such that the program works similarly to the1-fizzbuzzprogram. - Complete the code for the conditional logic in
index.jsin the3-reverse-stringfolder such that the program properly identifies that a string has been inputted and returns the reversed string as output. - Complete all of the associated TODOs in
index.jsin the4-reverse-string-iteratefolder such that the program properly identifies that a string has been inputted and returns the reversed string by iterating through the full length of the string. - Complete all of the associated TODOs in
index.jsin the5-character-countfolder in order to correctly recognize a string, count the characters in the string, and output the number of each character (sorted in order of frequency).
For assistance on how to proceed with specific components of the assignment, consult this text tutorial for guidance. In the alternative, a video walkthrough of the assignment can be found here. Timestamps for specific parts of the assignment (with associated links) are as follows:
- 2:32 - Part 1 of 5, 1-fizzbuzz
- 10:44 - Part 2 of 5, 2-fizzbuzz-fun
- 15:27 - Part 3 of 5, 3-reverse-string
- 18:58 - Part 4 of 5, 4-reverse-string-iterate
- 27:01 - Part 5 of 5, 5-character-count
- Write a variant of
1-fizzbuzzor2-fizzbuzz-funthat uses two separateifstatements and string addition instead of the four partif-elsestatement. - In the exercise
4-reverse-string-iterate, complete the STRECH TODOs in order to reverse the string by only iterating through half of its length. - Write an alternative version of
4-reverse-string-iteratethat uses afor ofloop. Learn more about thefor ofloop on the MDN JavaScript web docs here. - For
3-reverse-stringand4-reverse-string-iterate, use the consolecommands console.time(<label>)andconsole.timeEnd(<label>)to see how long each method takes. - In the exercise
5-character-count, also display the character counts in alphabetical order.