Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. const repeatNumbers = function(data) {
  2. // Put your solution here
  3.  
  4. let arrstring = "";
  5. let value = 0;
  6. let count = 0;
  7. // let sum = 0;
  8.  
  9. for (var i = 0; i < data.length; i++) {
  10.  
  11. value = data[i][0];
  12. count = data[i][1];
  13.  
  14. for (var j = 0; j < count; j++){
  15.  
  16. if ( j !== (count - 1) || i === (data.length - 1)) {
  17.  
  18. arrstring = arrstring + value
  19.  
  20. } else {
  21.  
  22. arrstring = arrstring + value + ','
  23.  
  24. }
  25.  
  26. }
  27.  
  28. }
  29.  
  30. return arrstring;
  31.  
  32. };
  33.  
  34. console.log(repeatNumbers([[1, 10]]));
  35. console.log(repeatNumbers([[1, 2], [2, 3]]));
  36. console.log(repeatNumbers([[10, 4], [34, 6], [92, 2]]));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement