Skip to content

Work with object, arrays, functions and iteration (for/of and for/in)

License

Notifications You must be signed in to change notification settings

suwebdev/wats-3020-node-2

Repository files navigation

WATS 3020 Node 2

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.

Topics covered by this Assignment:

Read more about these topics in the local file reference.md.

Basic Requirements

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.js in the 1-fizzbuzz folder 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.js in the 2-fizzbuzz-fun folder such that the program works similarly to the 1-fizzbuzz program.
  • Complete the code for the conditional logic in index.js in the 3-reverse-string folder 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.js in the 4-reverse-string-iterate folder 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.js in the 5-character-count folder 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).

Guide & Tutorial

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:

Stretch Goals

  1. Write a variant of 1-fizzbuzz or 2-fizzbuzz-fun that uses two separate if statements and string addition instead of the four part if-else statement.
  2. 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.
  3. Write an alternative version of 4-reverse-string-iterate that uses a for of loop. Learn more about the for of loop on the MDN JavaScript web docs here.
  4. For 3-reverse-string and 4-reverse-string-iterate, use the console commands console.time(<label>) and console.timeEnd(<label>) to see how long each method takes.
  5. In the exercise 5-character-count, also display the character counts in alphabetical order.

About

Work with object, arrays, functions and iteration (for/of and for/in)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •