[React Native Tutorial] Lecture 3: More on ES6/ES2015
1. Lecture 3: Additional
Materials for ES6
ES6 on Windows + More ES6 + More
Exercises
Kobkrit Viriyayudhakorn, Ph.D.
CEO of iApp Technology Limited.
kobkrit@gmail.com
http://www.kobkrit.com
14. Alias is not persistence!
• If you closed the command line windows, enter c:
es6 again, and always run link.cmd
• Open command line program
• cd c:es6
• link.cmd
• babel-node somefile.js
19. Exercise
(1) Write down a function that sum every element in
array. E.g. sumArray([12,3,4,1,2,3]) = 25
sumArray([12,3,4,1,2,3]); //=> 25
sumArray([1,2,3]); //=> 6
21. Exercise
(2) Write function that count word size case-insensitively.
wordHistogram('Hello world hello earth')
//=> {hello : 2, world : 1, earth : 1 }
wordHistogram('dog eat cat cat eat dog')
//=> {dog : 2, eat : 2, cat : 2 }
wordHistogram('Na na na na na na na na na
na na na na na na na na na na na na na na
na Batman!’)
//=> {Batman! : 1, na: 24}
(https://www.youtube.com/watch?v=EtoMN_xi-AM)
23. Exercises
(3) Write the function that can unions two arrays and
sort it ascendingly.
unionsAndSort([5,3,2],[1,4,5]) // =>
[1,2,3,4,5,5]
unionsAndSort([1,2,3],[4]) // =>
[1,2,3,4]
25. Exercises
(4) Write the function that select only words that start
with letter ‘a’ or ‘A’ in a string.
onlyStartWithA(‘angulus is an angle in
latin’); //=> ‘angulus an angle’
onlyStartWithA(‘apple is not an
animal’); //=> ‘apple an animal’