JavaScript by Radu TM β’ June 17, 2022
// create an array with emoji fruits
var fruits = ['π', 'π', 'π'];
// move the element at index 1 (π) to the end of the array
fruits.push(fruits.splice(1, 1)[0]);
// fruits is now ['π', 'π', 'π']
// move the element at index 2 (π) to the beginning of the array
fruits.unshift(fruits.splice(2, 1)[0]);
// fruits is now ['π', 'π', 'π']
0
17.976
JavaScript by Radu TM β’ June 17, 2022
var fruits = ["π", "π", "π", "π"];
//change the position of "π" to the end of the array
var apple = fruits.shift();
fruits.push(apple);
console.log(fruits); //["π", "π", "π", "π"]
0
17.976