- Javascript
- HTML
- CSS
A user can input any number into this application to receive a count from zero up to their number. For fun, the app makes the following number replacements:
- All numbers containing a 3 are replaced with the phrase "Won't you be my neighbor?"
- All numbers containing a 2, but no 3, are replaced with "Beep!"
- All numbers containing a 1, but no 2 or 3, are replaced with "Boop!"
Users can replace their number in the input field to get a new count as many times as they'd like.
- Clone this repository to an empty folder or to your desktop.
Instructions for cloning can be found here. - Navigate to the top level of the roboger directory
- Open index.html in your browser
- Input a number into the field next to "How High Should We Count?"
- Click the "Count!" button
- View your fun number list
Describe: beepBoop()
1. Test: "It should return an array with a 0 if the number 0 is inputted"
Code: beepBoop(0);
Expected Output: 0
2. Test: "It should return the number entered and all preceding numbers as an array"
Code:
beepBoop(5);
Expected Output: [0, 1, 2, 3, 4, 5]
3. Test: "It should replace any 3s entered with 'Won't you be my neighbor?'"
Code:
beepBoop(3);
Expected Output: [0, 1, 2, "Won't you be my neighbor?"]
4. Test: "It should replace any 2's entered with 'Boop!'"
Code:
beepBoop(2);
Expected Output: [0, 1, "Boop!"]
5. Test: "It should replace numbers including 2 and 3 with 'won't you be my neighbor,' NOT 'Boop!'"
Code:
beepBoop(23);
Expected Output: [0, 1, "Boop!", "Won't you be my neighbor?", 4, 5, 6, 7, 8, 9, 10, 11, "Boop!", "Won't you be my neighbor?", 14, 15, 16, 17, 18, 19, "Boop!", "Boop!", "Boop!", "Won't you be my neighbor?"]
6. Test: "It should replace any 1's entered with 'Beep!'"
Code:
beepBoop(1);
Expected Output: [0, "Beep!"]
// A friend said tests should be written more like this, if I was understanding correctly. I'm including both versions for now, since I'm not sure:
Describe: beepBoop()
1. Test: "It should return an array with a 0 if the number 0 is inputted"
Code: beepBoop(0);
Expected Output: 0
2. Test: "It should return the number entered and all preceding numbers as an array"
Code:
beepBoop(5);
Expected Output: [0, "Beep!", "Boop!", "Won't you be my neighbor?", 4, 5]
3. Test: "It should replace any 3s entered with 'Won't you be my neighbor?'"
Code:
beepBoop(3);
Expected Output: [0, "Beep!", "Boop!", "Won't you be my neighbor?"]
4. Test: "It should replace any 2's entered with 'Boop!'"
Code:
beepBoop(2);
Expected Output: [0, "Beep!", "Boop!"]
5. Test: "It should replace numbers including 2 and 3 with 'won't you be my neighbor,' NOT 'Boop!'"
Code:
beepBoop(23);
Expected Output: [0, 1, "Boop!", "Won't you be my neighbor?", 4, 5, 6, 7, 8, 9, 10, 11, "Boop!", "Won't you be my neighbor?", 14, 15, 16, 17, 18, 19, "Boop!", "Boop!", "Boop!", "Won't you be my neighbor?"]
6. Test: "It should replace any 1's entered with 'Beep!'"
Code:
beepBoop(1);
Expected Output: [0, "Beep!"]
- forEach version does not properly replace all digits of 2-digit+ integers including 1, 2, 3
- Not quite a "bug," but the count currently displays without spaces between its output items. This will hopefully be fixed someday.
GPL Copyright (c) 2021, Melissa Schatz-Miller
Melissa Schatz-Miller melissa.scmi@gmail.com
Please feel free to reach out to me with suggested changes/improvements, or if you have any questions.