function square(arr) {
const newArr = arr.map(x => x * x );
return newArr ;
//if you find this answer is useful ,
//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)
let dailyActivities = ['sleep', 'work', 'exercise']
let newRoutine = ['eat'];
// sorting elements in the alphabetical order
dailyActivities.sort();
console.log(dailyActivities); // ['exercise', 'sleep', 'work']
//finding the index position of string
const position = dailyActivities.indexOf('work');
console.log(position); // 2
// slicing the array elements
const newDailyActivities = dailyActivities.slice(1);
console.log(newDailyActivities); // [ 'sleep', 'work']
// concatenating two arrays
const routine = dailyActivities.concat(newRoutine);
console.log(routine); // ["exercise", "sleep", "work", "eat"]
//ADD ELEMENTS
//PUSH - adds elements to the END OF ARRAY
const friends = ["Zizi", "Ioseb", "Maiko"];
const newLength = friends.push("Karina");
console.log(friends); //["Zizi", "Ioseb", "Maiko"]
console.log(newLenght); //["Zizi", "Ioseb", "Maiko", "Karina"]
//UNSHIFT - add elements to BEGINNING OF THE ARRAY
friends.unshift("Baqso");
console.log(friends); //["Baqso", "Zizi", "Ioseb", "Maiko", "Karina"]
//REMOVE ELEMENTS
//POP - removes LAST ELEMENT FROM ARRAY
friends.pop(); //["Karina"]
//returns removed element
const popped = friends.pop();
console.log(popped); //["Karina"]
console.log(friends); //["Baqso", "Zizi", "Ioseb", "Maiko"]
//shift - Removes FIRST ELEMENT FROM THE ARRAY
friends.shift(); //["Baqso"]
console.log(friends); //["Zizi", "Ioseb", "Maiko"]
//indexOf - Tells the position of the element in the ARRAY
console.log(friends.indexOf("Zizi")); //0
//if we write the element which is not in the ARRAY we get : -1
console.log(friends.indexOf("zizi")); //-1, we need to write in CamelCase
//includes - modern method of indexOf
//includes - testing with STRICT EQUALITY
console.log(friends.includes("Zizi")); //true