Can you resolve this HTML and JavaScript problem?

Question by Ali: Can you resolve this HTML and JavaScript problem?
This is my whole HTML document:

function typename(){
name=prompt(‘What is your name?’,’Your name here’)

You didn’t enter your name, so you will be redirected automatically to another page in seconds.

nameparts=name.split(‘ ‘)
name=nameparts.join(‘ ‘)

Hello, ‘+name+’. Welcome to your page.



Please Enter Your Name Here:

I want this script to Capitalize each word’s first letter.
For example change “bill gates” to “Bill Gates”.
How can I do that?

Best answer:

Answer by Ck
it’s a css style, text-transform: capitalize;

so if your wanting to do it in the javascript you’ll need to write: = ‘capitalize’;

What do you think? Answer below!

Add a Comment

Your email address will not be published. Required fields are marked *