Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 74074

Make the first letter of the variable uppercase using Javascript for HTML

$
0
0

I am trying to print out my result using 'innerHTML'

  if (userChoice === computerChoice) {
    console.log("Tie!");
    result_h3.innerHTML =
      userChoice + " and " +
      computerChoice +
      " are both the same. It's a draw!";

How can I make the first letter of the userChoice variable come out in capital on the browser?

I tried:

  if (userChoice === computerChoice) {
    console.log("Tie!");
    result_h3.innerHTML =
      userChoice.value.charAt(0).toUpperCase() +
      userChoice.value.slice(1).toLowerCase() +
      +" and " +
      computerChoice +
      " are both the same. It's a draw!";

It didn't work.


Viewing all articles
Browse latest Browse all 74074

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>