/JavaScript-exercises-week2

JavaScript exercises for week 2

Primary LanguageJavaScript

js_exercises_week2

JavaScript exercises for week 2

Part 1

  1. Create an array and add three numbers to it.
  2. Use your array to return the second number.
  3. What data type is 123/12? "Things in quotes!"? undefined?
  4. Write an if statement that returns true.
  5. Consider these two arrays: myArray = ['Thomas', 'Amber', 'Raoul'] and emptyArray = []. Use a for loop to add our names to emptyArray. (Hint: n needs to be the length of the array. Google a helper method for finding the length of an array in Javascript. Is it the same as Ruby?)

Part 2

  1. Write a function that returns your first name. Call it.
  2. Write a new function that takes your name as an input. The function should return your first name, plus your last name, as one string. (Hint: strings can be combined with a +)

Part 3

  1. What is this? Does it have an equivalent in Ruby?
  2. Convert the above Person class to an ES2015 version using the new class syntax