Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda