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 trial

JavaScript JavaScript Loops, Arrays and Objects Tracking Data Using Objects Review Loops, Arrays, and Objects

AYMERIC FIGEROU
AYMERIC FIGEROU
3,748 Points

Last Quiz Questions:

Hello,

I would like to know what's the following answer for:

1st Questions Complete the code below. Use a method you were taught in this course to remove the last item from the students array. (Hint: don't forget the parentheses)

var lastStudent = students. ANSWER;

2nd Questions: Complete the code below to display every property and value of an object named location: ANSWER ( property.ANSWER location ) { document.write('<p>' + property + ':' + location[property] + '</p>');

If you add an explenatory line, it will be great. I have reviewed the video, and didn't not quite understand what is it asked.

Thanks you for reading and answering

Emmanuel Plouvier
Emmanuel Plouvier
11,919 Points

Hi,

For the first answer you must use the pop() method MDN pop().

For the second answer it a for ... in loop MDN For in Loop

3 Answers

Jacek Szemplinski
Jacek Szemplinski
6,423 Points

1st)

var lastStudent = students.pop();

pop() removes the last item from specified array and returns it, so now the last student is placed within the variable lastStudent

2nd)

for ( property in location ) { 
  document.write('' + property + ':' + location[property] + '');
}

Just a for...in loop, you can find in-depth explanation on MDN Website

For your first question, you'll want to use .pop() (see: this for more ).

For the second question, you'll want to use the 'for...in...' statement (see: this for more).