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 The Student Record Search Challenge Solution

Hui Zheng
PLUS
Hui Zheng
Courses Plus Student 1,380 Points

My prompt dialogue didn't pop up

https://w.trhou.se/22d2s0v0wn

I did everything else exactly same as what was shown in the video except I got rid of the other js file and combined the code in the file to the current js file that was created. Besides that I had also checked the html file and removed the extra script tag for the other js file. In terms of the code, I had double checked to make sure I hadn't omitted any curly braces or had any typos, nonetheless the prompt dialogue didn't pop up when I opened up the browser.

1 Answer

Your student_report.js file is in a folder named js. So it will have to be referenced in index.html as

<script src="js\student_report.js"></script>
Hui Zheng
Hui Zheng
Courses Plus Student 1,380 Points

Hi, professor. I have another question regarding the parameter student that was passed onto one of the functions. Initially, the variable student was declared without a value, then inside the for loop we assigned it the object literal students[i]. I know any variables declared inside a function have local scope and can't be accessed outside that function, but what about inside a for loop since student = students[i];. Also I was practicing with functions lately and here is the code I wrote which I didn't know what were the mistakes I made, and I would like to know if I could concatenate/adding the call property of a function calculatePrice() to other variables as I did here. Thanks

const taxRate = 0.08; const gamePrice = 50.99; const PS4 = 299.99;

var bankBalance = 400.88; var remainingAmount = parseInt(prompt("What is the spending amount?"));

function calculatePrice(remainingAmount){ remainingAmount = remainingAmount + remainingAmount * taxRate; return remainingAmount.toFixed(2); }

var totalAmount = calculatePrice() + gamePrice + PS4; while (totalAmount < bankBalance) { alert("The amount is within budget." + "<br>" + "$" + totalAmount); if (totalAmount > bankBalance){ alert("Not enough money.") } }