Skip to content

Instantly share code, notes, and snippets.

@jasonm23
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonm23/22295299106018e87473 to your computer and use it in GitHub Desktop.
Save jasonm23/22295299106018e87473 to your computer and use it in GitHub Desktop.

CoffeeScript Developer Questionnaire

1. What will x be?

x = 0
x = 4 if a?

2. What will y be?

y = [10..1]

3. What will z.b be?

z =
  a: 120
  b: 10
  c: 30

4. What will a[1] be?

a = [
     10
     20
     30
    ]

5. What will x be?

a = 1

x = 0
x = 10 if a?

6. What will x be?

a = 1
x = 0
x = 7 unless a?

7. What will z be?

z = 0
z ?= 10

8. Look at these classes:

class Vehicle
  constructor: (@name)->
  wheels: 0
  howManyWheels: ->
    alert "#{@name} has #{wheels} wheels."

class Bus extends Vehicle
  wheels: 4

class Bicycle extends Vehicle
  wheels: 2

We create these two instances:

redBus = new Bus "Red Bus"

blueBicycle = new Bicycle "Blue Bicycle"

8.1 What will we see when we run:

redBus.howManyWheels()

8.2 What will we see when we run:

blueBicycle.howManyWheels()

9. What is the value of a?

b = 10
a = if 3 > b then 10 else 100

10. What is the value of b?

[a, b, c] = [10, 30, 41]

11. What is the value of x?

x = ->
    a = 10
    b = 10 * a
    c = a + b
    [a, b, c]

12. What is the value of z?

o =
  a: 20
  b: 32
  c: 87
  d:
     t: [
         1, 0, 1
         0, 1, 0
         1, 0, 1
     ]
     y: [
       10
       43
       56
     ]

{d: {y: [z, x]}} = o
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment