Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

121
Vistas
Why is a number logged but not a string

What I Want to Happen

I have a function called playRound() that returns a string and then increments a number. What should happen is that both of these are logged.

What is Happening Instead

When I console.log the function, only a number is logged. It seems to be one of the numbers that is being incremented. I have a separate function to find out what the numbers are after they're incremented so this isn't specifically what I'm looking for.

What I have Tried so Far

I tried creating a second function to log just the strings, but I couldn't get it to work without having to change some code on playRound().

I thought maybe there was a way to only log strings. Tried looking around the internet but I didn't find anything related to my question.

My Code

function playRound(playerSelection, computerSelection) {
            if (playerSelection === "rock" && computerSelection === "rock") {
                return "Draw!" && ties++;
            } else if (playerSelection === "rock" && computerSelection === "paper") {
                return "You lose!" && compScore++;
            } else if (playerSelection === "rock" && computerSelection === "scissors") {
                return "You win!" && myScore++;
            } else if (playerSelection === "paper" && computerSelection === "paper") {
                return "Draw!" && ties++;
            } else if (playerSelection === "scissors" && computerSelection === "scissors") {
                return "Draw!" && ties++;
            } else if (playerSelection === "scissors" && computerSelection === "paper") {
                return "You win!" && myScore++;
            } else if (playerSelection === "scissors" && computerSelection === "rock") {
                return "You lose!" && compScore++;
            } else if (playerSelection === "paper" && computerSelection === "scissors") {
                return "You lose!" && compScore++;
            } else if (playerSelection === "paper" && computerSelection === "rock") {
                return "You win!" && myScore++;
            } else {
                return "Invalid input! Try again!" && invalidScore++;
            }
        }

        console.log("Here's the breakdown! Your Score, Computer Score, Ties, and the Invalid Score. ") + console.log(myScore, compScore, ties, invalidScore);
    } 

Please help me understand what I'm doing wrong, thank you.

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda