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
Step: 1
Heres a JavaScript function named capitalizeName that capitalizes the first letter of each word in a ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started