I need to write a program that prints out an array, removes the first two elements of the array using arr.remove(i), and then prints out the new array. My program correctly removes the first two elements, but I am having trouble with getting the program to print out the lists in the correct format.
The program should print out:
Sam, Lisa, Laurie, Bob, Ryan
Laurie, Bob, Ryan
My program prints out:
Sam, Lisa, Laurie, Bob, RyanLaurie, Bob, Ryan
This is my program:
function start(){
var arr = ["Sam", "Lisa", "Laurie", "Bob", "Ryan"];
for(var i = 0; i < arr.length; i++){
print(arr[i]);
if(i < arr.length - 1){
print(", ");
}
}
var elem = arr.remove(0);
var elem2 = arr.remove(0);
for(var i = 0; i < arr.length; i++){
print(arr[i]);
if(i < arr.length - 1){
print(", ");
}
}
}
How can I fix this program so that it prints the new list on a different line?