What is the output of the following code?
let items = new Array('apple','orange','cherry','lime'); let sep = '*'; concatenateString(items,sep);/*from ww w. j av a 2 s . c o m*/ console.log(items); function concatenateString(strings, separator) { let result=""; for (let i = 0; i < strings.length; i++) { result+=strings[i] + separator; } // assign result to separator separator = result; // and array strings[strings.length]=result; }
[ 'apple', 'orange', 'cherry', 'lime', 'apple*orange*cherry*lime*' ]