Coffee on the Range

Create an array with numbers 1 until 10 using the inclusive (two dot) range syntax.

[1..10]

Coffee on the Range II

Create an array with numbers 1 through 10 using the exclusive range syntax.

Exclusive ranges are defined using three dots between integers, inside square brackets
[1...6] Exclusive ranges do not include the last number.
values = [1...5]
# this expands to [1, 2, 3, 4] The answer is
[1...11]

Object Literals

Create a variable named coffee which is an object with a name property set to 'Russian', alevel property set to 2 and an isRussian property which holds a function that returns true. Use an object literal.

coffee =
name: 'Russian'
level: 2
isRussian: ->
true

or In Loop

Using the for element in collection loop, iterate over the people collection and print the names of people over 18 years old (person.age > 18). Use the console.log function to print the person.name.

for person in people
  console.log(person.name) if person.age > 18

List Comprehension

Modify the loop below to use a list comprehension.

console.log "#{person.name}" for person in people when person.age > 18

List Comprehension II

Refactor the code below to make use of list comprehension.

addCoffee coffee for coffee in coffeeList when not coffee.isRussian?()

Splat Arguments

Change the displayTopPicks function to accept a variable number of suggested coffees by using the splat operator. Use suggested.join(", ") to alert all of the suggested coffees.

displayTopPicks = (bestCoffee, suggested...) ->
alert('Top #1 ' + bestCoffee)
alert('Suggested: ' + suggested.join(","))

[CoffeeScript] Level 4 Arrays, Objects, Iterations -- Ex的更多相关文章

  1. coffeescript 1.8.0 documents

    CoffeeScript is a little language that compiles into JavaScript. Underneath that awkward Java-esque ...

  2. coffeescript 1.6.3使用帮助

    CoffeeScript is a little language that compiles into JavaScript. Underneath that awkward Java-esque ...

  3. Tempo 2.0

    Tempo 2.0 Tempo is an easy, intuitive JavaScript rendering engine that enables you to craft data tem ...

  4. how to use coffee script

    TABLE OF CONTENTS TRY COFFEESCRIPT ANNOTATED SOURCE CoffeeScript is a little language that compiles ...

  5. mysql 5.7.17发布

    Mysql 5.7.17发布了,主要修复: Changes in MySQL 5.7.17 (2016-12-12, General Availability) Compilation Notes M ...

  6. Attacking JavaScript Engines: A case study of JavaScriptCore and CVE-2016-4622(转)

    转:http://phrack.org/papers/attacking_javascript_engines.html Title : Attacking JavaScript Engines: A ...

  7. Zend API:深入 PHP 内核

    Introduction Those who know don't talk. Those who talk don't know. Sometimes, PHP "as is" ...

  8. iPhone Tutorials

    http://www.raywenderlich.com/tutorials This site contains a ton of fun written tutorials – so many t ...

  9. Faster, more memory efficient and more ordered dictionaries on PyPy

    Faster, more memory efficient and more ordered dictionaries on PyPy https://morepypy.blogspot.com/20 ...

随机推荐

  1. just test Gson

    just test Gson code package com.qilin.test; import com.google.gson.Gson; import org.apache.commons.l ...

  2. scala初学

    起因:新公司的程序用scala,为了不落后,不落伍,跟上时代的浪潮,咱们测试也得学学新东西 适合读者:有java经验的IT人士 scala:所有变量都是对象,所有操作都是方法 1.定义变量:变量:类型 ...

  3. Zookeeper Hello World

    1.Zookeeper的安装使用 在官网上下载zk的安装包(http://labs.renren.com/apache-mirror/zookeeper/),解压后cd到zk的目录下. 单机版安装方法 ...

  4. oracle 体系结构解析

    三.oracle 体系结构 1.oracle内存由SGA+PGA所构成 2.oracle数据库体系结构数据库的体系结构是指数据库的组成.工作过程与原理,以及数据在数据库中的组织与管理机制. oracl ...

  5. Java Web高性能开发(二)

    今日要闻: 性价比是个骗局: 对某个产品学上三五天个把月,然后就要花最少的钱买最多最好的东西占最大的便宜. 感谢万能的互联网,他顺利得手,顺便享受了智商上的无上满足以及居高临下的优越感--你们一千块买 ...

  6. linux中的配置文件

    /etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行.并从/etc/profile.d目录的配置文件中搜集shell的设置. /etc/bashrc:为每一个 ...

  7. Openstack之Swift架构(Cloud Storage)

    Swift是OpenStack的子项目之一,也称为对象储存,适用于储存永久类型的静态数据,例如:虚拟机镜像文件.图片.存档备份等 复制的三个副本如何联系在一起? 让我们用一些具体场景和介绍一些组件,来 ...

  8. BootCamp支持软件4/5

    按 Mac 机型列出的 Boot Camp 要求 不同的 Mac 电脑适用不同版本的 Windows.如果您不知道您拥有的 Mac 是什么机型,请从 Apple 菜单中选取“关于本机”. 每个表格条目 ...

  9. TQImport3XLS.Map

    property Map: TStrings; 设置数据集字段和Excel单元格之间定义映射属性以下列方式: FieldName=CellRange 导入单独的单元格 Field1=A1 Field1 ...

  10. 使用Map List 封装json数据

    <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</art ...