Multiply by Length

Published by Matt in

Create a function to multiply all of the values in an array by the amount of values in the given array.

Examples

multiply_by_length([2, 3, 1, 0]) ➞ [8, 12, 4, 0]

multiply_by_length([4, 1, 1]) ➞ ([12, 3, 3])

multiply_by_length([1, 0, 3, 3, 7, 2, 1]) ➞  [7, 0, 21, 21, 49, 14, 7]

multiply_by_length([0]) ➞ ([0])

Notes

  • All of the values given are numbers.
  • All arrays will have at least one element.
  • Don't forget to return the result.
Watch a quick demo on how Edabit works.