Programming Videos

  • View all videos
  • blank
  • Functions in JavaScript
    mrdaniel published this on 1/3/16 | javascript, functions
    Comments
  • +
  • 17
  • -
  • The function written took each element and squared it rather than doubled it. Just a typo rather than a conceptual error but thought you might like to know.
  • +
  • 2
  • -
  • i++
    means each iteration of the loop it will incrament by 1.
  • +
  • 2
  • -
  • To kevindchan, var result = [] is where the answers will be stored. on the fourth line you see result.push(arr[i] * arr[i]); result is listed again, so each time the calculation is being performed it is being stored in result. push allows you to add items into an array. The push will allow you to get your results in the same order as they appear in the array.
  • +
  • 1
  • -
  • Hi All, what is the purpose of "var result = [];" in the doubling function?
  • +
  • 0
  • -
  • @kevindchan the purpose is to store data that will be printed later as result.
  • +
  • 0
  • -
  • what does i++ means
    Log in to submit a comment.