languages = ['CoffeeScript', 'JavaScript', 'Ruby', 'Python']
learn(languages)
Expected Result:
> CoffeeScript is CS
> JavaScript is JS
> Ruby works with Ruby on Rails
> Python works with Django
languages = ['CoffeeScript', 'JavaScript', 'Ruby', 'Python']
learn(languages)
Expected Result:
> CoffeeScript is CS
> JavaScript is JS
> Ruby works with Ruby on Rails
> Python works with Django
languages = [
"CoffeeScript"
"JavaScript"
"Ruby"
"Python"
]
console.log languages
learnLanguages = (array) ->
for i in array
if i == "CoffeeScript"
console.log "#{i} is CS"
else if i == "JavaScript"
console.log "#{i} is JS"
else if i == "Ruby"
console.log "#{i} works with Ruby on Rails"
else
console.log "#{i} works with Django"
console.log learnLanguages(languages)
languages = ["CoffeeScript", "JavaScript", "Ruby", "Python"]
learn = (languages) ->
for lang in languages
console.log "CoffeScript is CS" if lang == "CoffeeScript"
console.log "JavaScript is JS" if lang == "JavaScript"
console.log "Ruby works with Ruby on Rails" if lang == "Ruby"
console.log "Python works with Django" if lang == "Python"
learn(["Ruby"])
#-> "Ruby works with Ruby on Rails"
languages = ['CoffeeScript', 'JavaScript', 'Ruby', 'Python']
learn = (languages) ->
for l in languages
switch l
when 'CoffeeScript' then console.log "#{l} is CS"
when 'JavaScript' then console.log "#{l} is JS"
when 'Ruby' then console.log "#{l} works with Ruby on Rails"
when 'Python' then console.log "#{l} works with Django"
learn languages