const weekDays = ["Sunday", "Tuesday", "Monday", "Wednesday"];
Objective is to remove Tuesday from the current position and then add it back in the right position. Go to this link https://www.w3schools.com/jsref/jsref_splice.asp for more details
var day = "Tuesday"
Step 2: this code means, at position 1, remove 1 item and store the result.Tuesday happens to be in that position.
weekDays.splice(1, 1)
Step 3: now time to add it back but in a different position using the day variable. This code means, at position 2, remove 0 items and add 1 item called day
weekDays.splice(2, 0, day)