Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
javascript - keep getting error with multiple equation with words and results

I am trying to get a result that looks like this

"The volume of the cone 261.66 is greater than the volume of the cylinder 785: false."

console.log("The volume of the cone " +(10 / 3 * (3.14 * (5 **2))) "is greater than the volume of the cylinder " +(10 * (3.14 * (5 **2)))): 261 > 785);

EDIT: Thanks for all your help everyone. I can believe I didn't see that I didn't put + and thanks for point out ":" I was so tired and I just wanted to finish I can't believe I wasted all that time getting the math to work just to miss a + and forgot about :

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You missed adding + or concatenation after the numerical expressions and : should have been in quotes too as its a string. Better yet use templating, both examples below:

// With concatination
console.log("The volume of the cone " + (10 / 3 * (3.14 * (5 ** 2))) + " is greater than the volume of the cylinder " + (10 * (3.14 * (5 ** 2))) + ": " + (261 > 785));

// With templating
console.log(`The volume of the cone ${(10 / 3 * (3.14 * (5 ** 2)))} is greater than the volume of the cylinder ${(10 * (3.14 * (5 ** 2)))}: ${(261 > 785)}`);

about 4 years ago · Juan Pablo Isaza Report

0

It should be one from below

String Concatenation

console.log("The volume of the cone " + (10 / 3 * (3.14 * (5 **2))) + "is greater than the volume of the cylinder " + (10 * (3.14 * (5 **2))) + ":" + (261 > 785));

Please Note the importance of the paranthesis in (261 > 785). Removing the bracket will throw a false as output. Because the string expression in console will be checked against > 785 if the bracket is removed, that will result in false as result

OR

Template Literals

console.log(`The volume of the cone  ${(10 / 3 * (3.14 * (5 **2)))} is greater than the volume of the cylinder ${(10 * (3.14 * (5 **2)))} : ${261 > 785}`);

about 4 years ago · Juan Pablo Isaza Report

0

You missed a + and ":"

With template literals

console.log(`The volume of the cone ${(10 / 3 * (3.14 * (5 **2)))} is greater than the volume of the cylinder ${(10 * (3.14 * (5 **2)))} : ${261 > 785}`);

Template literals

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!