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

add it to the temperatures array at the index that correpsonds with the day of week

Get the user inputted temp and validate it making sure it's a number if it's valid add it to the temperatures array at the index that correpsonds with the day of week, e.g. 0 for Monday, 2 for Wednesday. and also loop through the non-undefined temperatures In the same loop sum the temperatures and count how many there are so you can calculate the average and output the average temp on the page.

Use a for loop here to write options to the select for each day of the week <option value="0">Monday</option> using += here with innerHTML property takes the existing values and concats this on the end .. i am just stuck . and don't know how to start.

1 Answer

Hey Paula, do you have any code you could share with us? It would be helpful to see any HTML you're trying to add interaction to.

Thank you Matt this is what i have so far.. "use strict"; var temperatures = []; var days = ["Monday", "Tuesday","Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];

var $ = function (id) { return document.getElementById(id); }

var takeTemps = function () { var tempIn = $("tempIn").value; if(isNaN(tempIn) || tempIn === ""){ alert("Please enter a number for temperature"); $("tempIn").value; $("tempIn").focus(); }

    temperatures.push(tempIn);