Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Javascript to begin in a new line

Ren SosaRen Sosa Member Posts: 8

I am new at javascript and probably this is super easy but for now it is something that I can not accomplish.

If I am wring a code where I prompt the user to provide me with a few names and then I want the output to be in a new single line. Also, I want the names in uppercase and to display the length.
This is my code but it is giving me all the names in a single line and not in a new line.

<!DOCTYPE html>

var names=prompt ("Name") names=prompt ("Name") document.write(names.toUpperCase()); document.write(names.length); names=prompt ("Name"); document.write(names.toUpperCase()); document.write(names.length);




Its giving me:
ANA3AMELIA6BRENDA6

I want:
ANA 3
AMELIA 6
BRENDA 6

Thanks!

Comments

  • B00B00 Member Posts: 115 ✭✭✭

    Doing JS in browser you have to use HTML tags for formatting. Choose one of these.

    document.write(names.toUpperCase() + "<br>");
    document.write("<p>" + names.toUpperCase() + "</p>");
    
  • Ren SosaRen Sosa Member Posts: 8

    Thanks B00! I was able to complete my homework!

Sign In or Register to comment.