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 trialChris Huynh
Full Stack JavaScript Techdegree Student 1,399 PointsEvaluate the code in app.js. The code currently produces a TypeError. Adjust the code so that the points variable holds
.....the expected value.
JavaScript Basics Challenge Task 1 of 1: Update the Value of a Variable.
Having trouble with the code, I've tried multiple times, don't know what to do, here's the code I wrote.
const points = 100; bonusPts = 50;
let points += 100; points = 50; console.log(points);
10 Answers
Steven Parker
231,141 PointsCongratulations on resolving your own issue.
As you discovered, a variable declared as "const" cannot be changed later in the code.
Farai Mukosera
7,093 PointsEvaluate the code in app.js. The code currently produces a TypeError. Adjust the code so that the points variable holds the expected value. const points = 100; const bonusPts = 50;
points += bonusPts; console.log(points);
somebody help I can't figure the answer
Steven Parker
231,141 PointsThe statement "points += bonusPts;
" would change "points" by adding the value of "bonusPts". But since "points" was declared as "const" it causes an error. Just declare "points" with "let" or "var" instead to allow it to be changed.
Chris Huynh
Full Stack JavaScript Techdegree Student 1,399 PointsTry
lets points = 100; bonusPts = 50; let points +=100; points = 50; console.log(points);
Steven Parker
231,141 PointsThat would also cause errors. In particular, "lets" should be "let" at the beginning, then remove the second "let" entirely. Note that even with the errors fixed, this code also has a very different functionality than the original.
Bujmaa Javzmaa
165 PointsChange const to LET (all of them) then it works. The lesson I learned here is we can not use Const more than one time
Steven Parker
231,141 PointsAnd even when you only use it one time, you cannot assign another value to that variable later!
Nnanna Okoli
Front End Web Development Techdegree Graduate 19,181 PointsVar points = 100; Var bonusPts = 50;
points += bonusPts; console.log(points);
Usman Naeem
Front End Web Development Techdegree Student 3,542 PointsHi guys,
this is the answer
const points = 100; let bonusPts = 50;
points.bonusPts; console.log(points);
Adam Gheli
2,091 PointsI'm still not able to figure this out. Not sure what I'm doing wrong.
jlovellealfeche
Front End Web Development Techdegree Student 7,738 PointsJust change all const to let statement
const points = 100; --> let points = 100;
Joan Bandoles
Courses Plus Student 435 Pointslet points = 100; var bonusPts = 50;
points += bonusPts; console.log(points);
Jade Nguyen
3,303 Pointsmy answer:
var points = 0; points += 100;
var bonusPts = 50; var finalpoints = points + bonusPts; console.log(finalpoints);
Shanze Saleem
1,091 PointsI just changed all the conts to let and it worked for me :)
Isaiah Gadson
6,398 Pointswhat is the answer because it is hard?
Chris Huynh
Full Stack JavaScript Techdegree Student 1,399 PointsChris Huynh
Full Stack JavaScript Techdegree Student 1,399 Pointsokay so i finally found the answer. it was swapping out the const with lets to allow the code run.