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 trialJoseph M.
2,057 Pointsaddittion of variables within literal-template
Hi, am adding two numbers within a literal template. instead, the two are being concatenated.
answer +=${num1} + ${num2} = ${num1 + num2}
;
kindly help
2 Answers
Robert Gulley
Front End Web Development Techdegree Student 10,722 PointsHi Joseph! -
Without being able to see all of your code, I'm going to assume that you are taking input from a user and then trying to add those two numbers. Are you using a unary plus or parseInt to convert these to numbers since user input is always a string regardless of what is typed?
Joseph M.
2,057 PointsHi Robert. Yes that is the issue thanks. done a bit of research and found that I could convert the string to integer using the parseInt function, and the addittion has worked out. thanks again.