This file contains hidden or 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
square = (x = 0) -> | |
x * x | |
sum = (x = 0, y = 0) -> | |
x + y | |
console.log(square(2)) | |
console.log(square()) | |
console.log(sum(10, 5)) | |
console.log(sum(3, 7)) | |
name = 'John' |
This file contains hidden or 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
'use strict' | |
const square = (x = 0) => { | |
return x * x | |
} | |
const sum = (x = 0, y = 0) => { | |
return x + y | |
} | |
console.log(square(2)) | |
console.log(square()) | |
console.log(sum(10, 5)) |
This file contains hidden or 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
say_hello = (name, job_position) -> | |
"Hello. My name is #{name}. And I am a #{job_position}" | |
console.log(say_hello('John', 'developer')) | |
console.log(say_hello('Eva', 'designer')) | |
cat = | |
name: 'cat' | |
say: 'meow' | |
say = (animal) -> | |
"#{animal.name} says #{animal.say}" |
This file contains hidden or 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
'use strict' | |
const say_hello = (name, jobPosition) => { | |
return `Hello. My name is ${name}. And I am a ${jobPosition}` | |
} | |
console.log(say_hello('John', 'developer')) | |
console.log(say_hello('Eva', 'designer')) | |
let cat = { | |
name: 'cat', | |
say: 'meow' |
This file contains hidden or 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
class Animal | |
constructor: (name)-> | |
@name = name | |
walk: ()-> | |
console.log("#{@name} is walking") | |
class Rabbit extends Animal | |
walk: ()-> | |
super() |
This file contains hidden or 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
'use strict' | |
class Animal { | |
constructor (name) { | |
this.name = name | |
} | |
walk () { | |
console.log(`${this.name} is walking`) | |
} | |
} |
This file contains hidden or 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
_loadDataForUser = (url, callback) -> | |
setTimeout(callback, 2 * 1000) | |
loadDataForUsers = (userNames) -> | |
for i in userNames | |
_loadDataForUser "users/#{userNames[i]}", ()-> | |
console.log('Fetching for ', i) | |
loadDataForUsers(['John', 'Eve', 'Oleg']) | |
# Fetching for Oleg |
This file contains hidden or 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
'use strict' | |
const _loadDataForUser = (url, callback) => { | |
setTimeout(callback, 2 * 1000) | |
} | |
const loadDataForUsers = (userNames) => { | |
for (var i in userNames) { | |
_loadDataForUser(`users/${userNames[i]}`, function () { | |
console.log('Fetching for ', userNames[i]) | |
}) | |
} |
This file contains hidden or 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
'use strict' | |
const _loadDataForUser = (url, callback) => { | |
setTimeout(callback, 2 * 1000) | |
} | |
const loadDataForUsers = (userNames) => { | |
for (let i in userNames) { | |
_loadDataForUser(`users/${userNames[i]}`, function () { | |
console.log('Fetching for ', userNames[i]) | |
}) | |
} |
This file contains hidden or 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
'use strict' | |
let groceryList = new Set() | |
groceryList | |
.add('Bananas') | |
.add('Apples') | |
.add('Grapes') | |
.add('Kiwis') | |
.add('Pears') | |
.add('Apples') // dublicates will be ignored |