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

115
Views
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
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!