Advertisement
-Annie-

PrintArrayWithGivenDelimiter

Jun 2nd, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let delimiter = input.pop();
  3.     let result = '';
  4.     let lastResult = '';
  5.  
  6.     for(let str of input) {
  7.         result += str + delimiter;
  8.         lastResult = result.substring(0, result.length - 1);
  9.     }
  10.  
  11.     console.log(lastResult);
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement