Skip to content

Instantly share code, notes, and snippets.

View BridgeNB's full-sized avatar

Yangqiao Zheng BridgeNB

View GitHub Profile
@BridgeNB
BridgeNB / noteFindMostFrequentWord
Created June 26, 2018 20:03
find most frequent word
1. getToken function takes a raw string converted to an array consisted words.
All words in that array are in lower cases, no punctuations and falsy items, sorted by alphabetical order.
2. mostFrequentWord function takes a raw string and use getToken to covert it to tokens.
Then build a dictionary (hash map) to count all words' frequency. Then use a loop to find the most frequent word.
1. https://repl.it/@BridgeNB/Make-student-reports-drill
2. https://repl.it/@BridgeNB/Enroll-in-summer-school-drill
3. https://repl.it/@BridgeNB/find-by-id-drill
4. https://repl.it/@BridgeNB/validate-object-keys-drill
@BridgeNB
BridgeNB / objectAnswers
Created June 26, 2018 19:02
answers to object drills 1
1. https://repl.it/@BridgeNB/Object-creator-drill-2
2. https://repl.it/@BridgeNB/Object-updater-drill-1
3. https://repl.it/@BridgeNB/Self-reference-drill
4. https://repl.it/@BridgeNB/Deleting-keys-drill
@BridgeNB
BridgeNB / Answers to scope
Created June 26, 2018 17:52
Answer for scope
1. Scope is the range where variables are defined and validated. Global scope is the environment
where variables are available everywhere in this project.
Local scope is a particular area where variables are vaildated, for example, a function or a file.
2. We have to avoid global variables to aviod misrable bugs.
3. In strict mode, you cannot use a variable without defined it first.
4. Side effects is that one function's output will affect other functions.
Pure funtion is that this function is both determinate and has no side affect.