Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBrad Richardson
Courses Plus Student 1,843 PointsHow do i display these numbers in order?
i can get the numbers to display, but they are not in order.
9 Answers
Sergey Podgornyy
20,660 PointsOrder of values in array is not important. Everything you need is:
for (i = 0; i < temperatures.length; i++) {
console.log(temperatures[i]);
}
Brad Richardson
Courses Plus Student 1,843 PointsI understand, but the task asks me to put the numbers in order.
Bummer! The items in the array weren't logged out in order. Your should log all the temperatures in order, starting at 100 and ending at 10.
Sergey Podgornyy
20,660 PointsIn challenge you need to:
Use a for
or while
loop to iterate through the values in the temperatures
array from the first item -- 100 -- to the last -- 10. Inside the loop, log the current array value to the console.
Or I am looking on another challenge?
Brad Richardson
Courses Plus Student 1,843 Pointsthats the right challenge
Sergey Podgornyy
20,660 PointsTry to add the following:
temperatures.sort();
temperatures.reverse();
for (i = 0; i < temperatures.length; i++) {
console.log(temperatures[i]);
}
Sergey Podgornyy
20,660 PointsOr
temperatures.sort(function(a, b){return b-a});
for (i = 0; i < temperatures.length; i++) {
console.log(temperatures[i]);
}
Brad Richardson
Courses Plus Student 1,843 Pointsvar temperatures = [100,90,99,80,70,65,30,10]; for ( var i = 0; i < temperatures.length; i += 1) {
} console.log(temperatures);
this code prints out this:
[100, 90, 99, 80, 70, 65, 30, 10]
but i still get this error:
Bummer! The items in the array weren't logged out in order. Your should log all the temperatures in order, starting at 100 and ending at 10.
Sergey Podgornyy
20,660 PointsPlease, use Markdown Cheatsheet for formatting your post. It's very hard to read your code.
Brad Richardson
Courses Plus Student 1,843 Pointsyour code worked, Tnx
Sergey Podgornyy
20,660 Pointsyou are welcome
Brad Richardson
Courses Plus Student 1,843 Points''' temperatures.sort(function(a, b){return b-a}); for (i = 0; i < temperatures.length; i++) { console.log(temperatures[i]); } '''
Im trying to figure out how to use the cheat sheet!!
Sergey Podgornyy
20,660 PointsYou need to write code inside backquotes `
You can find this button above Tab
Brad Richardson
Courses Plus Student 1,843 Pointstemperatures.sort(function(a, b){return b-a});
for (i = 0; i < temperatures.length; i++) {
console.log(temperatures[i]);
}
Brad Richardson
Courses Plus Student 1,843 Pointstemperatures.sort(function(a, b){return b-a});
for (i = 0; i < temperatures.length; i++) {
console.log(temperatures[i]);
}
Brad Richardson
Courses Plus Student 1,843 PointsAhh :) thanks again
Sergey Podgornyy
20,660 PointsYou are welcome ;)
May the Force be with you, young Padawan
Sergey Podgornyy
20,660 PointsQui-Gon =))
Brad Richardson
Courses Plus Student 1,843 PointsBrad Richardson
Courses Plus Student 1,843 Pointsvar temperatures = [100,90,99,80,70,65,30,10]; for ( var i = 0; i < temperatures.length; i += 1) { } console.log(temperatures);