Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var repeatNumbers = function(data) {
- return data.map(([number, count]) => number.toString().repeat(count)).join(', ')
- }
- console.log(repeatNumbers([[1, 10]]));
- console.log(repeatNumbers([[1, 2], [2, 3]]));
- console.log(repeatNumbers([[10, 4], [34, 6], [92, 2]]));
- // 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