Q:

Splitting a string of numbers into an array

I keep getting an error in the console that .split is not a function. Here is my code:
function addEnds(list) {

        var array = new Array();
        array = list.split(',');

        console.log(array);
    }

Basically, I want the list to equal a series of number separated by a comma, example: 1,2,3,4,5, and am trying to put those into an array.  I've researched about using .split but for some reason, I'm just not getting it.

A:

The function shared is working absolutely fine. Just ensure that the argument that you are passing is a string.
Please follow the below fiddle:
https://jsfiddle.net/6pennzrb/
function addEnds(list) {
    var array = new Array();
    array = list.split(',');
    console.log(array);
}
addEnds("1,2,3,4,5")

