Created
June 10, 2017 10:59
-
-
Save kabaros/560c171eb5cb741bdaa289f9a179114a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For Students | |
Think about the solution before writing any code (maybe even write pseudocode, or pencil a solution) | |
Break bigger tasks into smaller pieces, and solve them one step at a time. | |
Think about your function signature | |
Write Test -> Write Code Implementation -> Refactor (repeat) | |
Use the debugger | |
Good functions | |
have good names and clear parameter names | |
have single responsibility | |
be defensive: don't trust your parameter | |
Good tests | |
have good test description | |
test for edge cases and unexpected behavior | |
---- | |
The class will be based on Find Alive people exercise on JS-TDD-Exercises repo | |
implement the basic example if you haven't (find alive people) | |
if you did, let the mentor review it | |
write a function findByAge that finds people over a certain age (age is a parameter) | |
signature: findByAge(age) | |
example: findByAge(60) returns every person over 60 | |
refactor findByAge to take a second paramter (boolean) that makes look for people below a certain age (rather than above) | |
example: findByAge(60, true) returns every person under 60 | |
findByAge(60, false) returns every person over 60 | |
this should be the same previous function - and the previous tests should not break | |
write a functon to find people by firstName or lastName | |
signature: findByName(name) | |
example: findByName("Smith") returns every person who has their first name or last name as "smith" | |
improve it to to match the start of the word not the whole word (add a test first) | |
write a function that performs a more generic version of this search | |
it should take an object that has two keys | |
findWriter({ | |
age: 60, | |
alive: true | |
}); // should return every person who is over 60 and alive | |
write a function called getStatistics that takes an array of writers and returns an object containing stats about the numbers of the writers alive | |
getStatistics(writersArray); | |
// response should be an object representing the statistics about how many are alive and how many are dead - sample response: | |
{ | |
alive: 2, | |
dead: 3 | |
} | |
More potential exercises | |
Write a function that accepts an array of words and finds the longest word | |
Example: ['Code', 'Your', 'Future'] | |
Returns: 'Future' | |
Think about your solution in plain English and write pseudocode | |
add more test cases to verify your solution | |
Write a function that accepts a Phrase (string) and finds the longest word | |
Example string : 'Code Your Future' | |
Expected Output : 'Future' | |
Can your new function reuse the previous function? | |
Write a JavaScript function that accepts a string as a parameter and counts the number of vowels within the string. | |
Note : As the letter 'y' can be regarded as both a vowel and a consonant, we do not count 'y' as vowel here. So the vowels are a, e, i, o, u | |
Example string : 'Code Your Future' | |
Expected Output : 6 | |
Write a JavaScript function that accepts a string as a parameter and returns an object containing how many times each vowel was repeated | |
Example string : 'Code Your Future' | |
Expected Output : | |
{ | |
o: 2, | |
e: 2, | |
u: 3 | |
} | |
Write a function that removes vowels from a phrase. | |
removeVowels("goodbye") // --> "gdby" | |
removeVowels("nodegirls") // --> "nd grls" | |
removeVowels('how are you today?') // --> "hw r y tdy?" | |
Update the function to have a second argument (a Boolean) - if it passed false, then it removes vowels - if passed true, then it removes consonants | |
removeVowels("goodbye", false) // --> "gdby" | |
removeVowels("goodbye", true) // --> "ooe" | |
Your updates on this step should not break the functionality in step 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment