We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

mc0re • 2 years ago

Array.reverse()
"the original array will not be affected" - this is not what the code shows. Type in:
var arr = [true, 2, 3, "4"];
new_array = arr.reverse()
console.log(new_array); // ["4", 3, 2, true]
console.log(arr); // ["4", 3, 2, true]

"arr" and "new_array" yield the same.

The same goes for Array.sort()

RunninglVlan • 2 years ago
Foxtrot • 1 year ago

thank you, this helped

vikas • 1 year ago

Given an array like
var arr = [(0,1,3),(-1,0,4),(-2,2,-5)];

How do I read each integer from this ?

Note: its small brackets inside square brackets

AmitGupta1 • 1 year ago
Anonymous • 1 year ago

Write a script which allows user to add numbers of top 5 students in the class. after user has added numbers of 5 students show the data in console log.
bonus... allow to add numbers only.. do not allow string or anything other than number

Armando Roque Barahona • 1 year ago

var odd_numbers = numbers.filter(item => item % 2);

i dont think its necessary to write var odd_numbers = numbers.filter(item => item % 2 == 1);

Very informative article great job.