Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript The Solution

addittion 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

Hi 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?

Hi 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.