-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathJStesting-practice.js
94 lines (68 loc) · 3.45 KB
/
JStesting-practice.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//For these exercises - write the function first, then write the test.....
//write a function returns "drink coffee" if you are tired and "keep working" if you are not tired. Then write the test.
//write a function returns "relax" if you are stressed and "keep going" if you are not stressed. Then write the test.
//Write a function that returns "in budget" if a price is lower than $300. Then write the test.
//write a functions that takes in two arguments(numbers) and returns the smaller number. Then write the test.
//Write a functions that takes in one argument(number) and returns whether the number is odd. Then write the test.
//Write a function that takes in a fruit and returns yellow if the argument is banana, red if apple and purple if grape. Then write the test.
//For these next exercises - Write the test first, make it fail, write the code then make it pass.....
// Exercise 1
// Write a function called Rick that returns "Morty".
// Exercise 2
// Write a function called greeter that takes a name as an argument and returns a greeting with that name to the screen.
// Exercise 3
// Write a function called oddOrEven that takes an number as an argument and logs whether the number is odd or even.
// Exercise 4
// Write a function called triple that takes an number as an argument and returns the result of that number multiplied by 2.
// Exercise 5
// Write a function called multiply that takes two numbers as arguments and logs the result of one of the numbers multiplied by the other.
// Exercise 6
// Write a function called divisibleBy that takes two numbers as arguments and returns whether the first number is evenly divisible by the second so that divisibleBy(10, 5) logs "10 is evenly divisible by 5".
// Exercise 7
// Consider this variable:
// var product = { name: "chair", price: 14.99 }
// Write a function called describeProduct takes product as an argument and returns "The product is a chair. It costs $14.99".
// Write a function that takes in an array of five numbers and returns a new array with every number multiplied by 3.
// write the tests
// make it fail
// write the Code
// make it pass
// refactor with map()
// make sure it still passes
// Write a function that takes in an array and saves all numbers in the numbers array that are evenly divisible by 3 into another array.
// write the tests
// make it fail
// write the Code
// make it pass
// refactor with filter()
// make sure it still passes
//
// For these, write the test, make it fail, write the code, make it pass
//
//
//
// The World Translator
// Write a function named helloWorld that:
//
// takes 1 argument, a language code (e.g. "es", "de", "en")
// returns "Hello, World" for the given language, for at least 3 languages. It should default to returning English.
// Test the function for each of the supported languages
//
//
// The Grade Assigner
// Write a function named assignGrade that:
//
// takes 1 argument, a number score.
// returns a grade for the score, either "A", "B", "C", "D", or "F".
// Test the function for a few different scores.
//
//
// The Pluralizer
// Write a function named pluralize that:
//
// takes 2 arguments, a noun and a number.
// returns the number and pluralized form of the noun, if necessary.
// pluralizer(5, cat) should return "5 cats"
// pluralizer(1, dog) should return "1 dog" because the number one does not require a plural noun
//
// Bonus: Make it handle a few collective nouns like "sheep", "geese", "children", "people" and "species".