Guest User

Untitled

a guest
Sep 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. var repeatNumbers = function(data) {
  2. return data.map(([number, count]) => number.toString().repeat(count)).join(', ')
  3. }
  4. console.log(repeatNumbers([[1, 10]]));
  5. console.log(repeatNumbers([[1, 2], [2, 3]]));
  6. console.log(repeatNumbers([[10, 4], [34, 6], [92, 2]]));
  7. // using map function to create new array and including other functions like "toString" to make into string and "join" to combine the other arrays together witha a comma.
Add Comment
Please, Sign In to add comment