04-04-2023, 07:43 AM
Code:
const fruits1 =
[
"Banana",
"Orange",
"Apple",
"Mango"
];
const fruits2 =
[
"Banana",
"Orange",
"Apple",
"Mango"
];
// Copy the first two elements to the last two elements
let text = fruits1.copyWithin(2, 0);
document.getElementById("output1").innerHTML = text;
// Copy the last two elements to the first two elements
let text2 = fruits2.copyWithin(0, 2);
document.getElementById("output2").innerHTML = text2;
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos