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 trialYifang kuo
Front End Web Development Techdegree Student 12,376 PointsI tried what Video said, but it doesn't work.
Can anyone tell me where I type wrong? Coz it keep showing error in console and I set parameter "start = 1" seems not working.
function countToFive(start=1) {
for(var i = start; i <= 5; i+=1) {
console.log(i);
}
}
countToFive(0);
Yifang kuo
Front End Web Development Techdegree Student 12,376 PointsIt works for me again after I tried another day. I guess is my browser have some cookies and made it not working. Thanks for helping.
1 Answer
Steven Parker
231,172 PointsDefault parameters are only available in browsers supporting ES6.
In case your browser does not, you can replace the top line with these two:
function countToFive(start) {
if (start === undefined) start = 1
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherInteresting. Your code works for me. What error are you receiving?