This is my code:
let numbers = [1, 2, 3, 4, 5]; let result = numbers.join('-'); console.log(result);
I anticipated the output to be 1-2-3-4-5, but I got 1-2-3-4-5- instead. There appears to be an additional hyphen at the end of the string. I studied the join() function documentation, and it appears that the separator should only be used between components, not at the end.
I’m not sure why this additional hyphen appears. Can somebody explain what I’m doing wrong and how to repair it? Your help would be highly appreciated!