The Concatenation Problem with Arrays and Strings

I’m working on a JavaScript project and I’m attempting to use the join() function to turn an array of integers into a comma-separated text similar to this example. However, I appear to be having a difficulty that I can’t seem to solve.

This is my code:

let numbers = [1, 2, 3, 4, 5];
let result = numbers.join('-');

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!