Question: Write a JavaScript function (name it: capitalizeName) to implement the following task: ** function capitalizeName(name) takes one string parameter. ** the parameter may be a

Write a JavaScript function (name it: capitalizeName) to implement the following task:

** function capitalizeName(name) takes one string parameter.

** the parameter may be a full name, separated by white space (" "), e.g.

Bryan stevenson

** your function will capitalize the first letter of

firstName,

middleName, and

lastName

** your function returns the new capitalized name as a string.

Note:

(1) the name could be FirstName LastName, FirstName MiddleName LastName, or random input.

(2) you only recognize the name separator of white space (" ").

(3) if the name is already capitalized, just leave it as is.

refer to the sample runs below.

Sample runs:

Test your function using the following statements and include them in your submission.

console.log(capitalizeName("Bryan stevenson"));

console.log(capitalizeName("jayce a. tapia"));

console.log(capitalizeName("math"));

console.log(capitalizeName("I love programming"));

console.log(capitalizeName("1+2+3"));

console.log(capitalizeName("Good Morning"));

result:

Bryan Stevenson

Jayce A. Tapia

Math

I Love Programming

1+2+3

Good Morning

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres a JavaScript function named capitalizeName that capitalizes the first letter of each word in a ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!