Write a JavaScript code to reverse the array colors without using the reverse method
.
Input:
const colors = ['red', 'blue', 'green', 'yellow', 'orange']
Output:
['orange', 'yellow', 'green', 'blue', 'red']
Write a JavaScript code to get the even numbers from an array using any looping technique.
Input:
const numbers = [12, 98, 5, 41, 23, 78, 46];
Output:
[12, 98, 76, 46]
Use a for...of loop to concatenate all the elements of an array into a single string.
Input:
var numbers = ['Tom', 'Tim', 'Tin', 'Tik']
Output:
'TomTimTinTik'
Reverse the words of a sentence. Only the position of the word will be reversed. check out the output
Input:
const statement = 'I am a hard working person'
Output:
'person working hard a am I'
Copy the given array into another array so that changing the copy does not affect the original.Change the first element of the copied array to 99.
Input: [1, 2, 3]
Expected Output:
Original: [1, 2, 3] Copy: [99, 2, 3]
Given an array of student objects, print each student’s name and marks.
[
{ name: "John", marks: 85 },
{ name: "Alice", marks: 90 }
]
John scored 85
Alice scored 90
Given a 2D array, update the value at second row first item to 99 and print the updated array.
input:
[
[1, 2],
[3, 4],
[5, 6]
]
Expected Array:
[
[1, 2],
[99, 4],
[5, 6]
]