Challenge: Write a Greeting Function
Task
Implement a function to output a sentence:
- Name the function
myName. - The function should accept one argument,
name. - The
myNamefunction body should contain aconsole.log()statement that prints the sentence"My name is {name}". - Call the
myNamefunction three times with different names.
1234567function ___(___) { console.log("My name is", ___); }; myName("___"); myName("___"); myName("___");
The output should be:
My name is {name}
My name is {name}
My name is {name}
- Function definition:Β
function funcName(argument) {}. - Place theΒ argument nameΒ inside theΒ
console.log()Β function. - Call the function with different names (choose them yourself).
- Call theΒ
funcNameΒ function after defining it using theΒfuncName(value)Β syntax.
1234567function myName(name) { console.log("My name is", name); } myName("Ashley"); myName("Ervin"); myName("Mabel");
Everything was clear?
Thanks for your feedback!
SectionΒ 6. ChapterΒ 3
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 2.33
Challenge: Write a Greeting Function
Swipe to show menu
Task
Implement a function to output a sentence:
- Name the function
myName. - The function should accept one argument,
name. - The
myNamefunction body should contain aconsole.log()statement that prints the sentence"My name is {name}". - Call the
myNamefunction three times with different names.
1234567function ___(___) { console.log("My name is", ___); }; myName("___"); myName("___"); myName("___");
The output should be:
My name is {name}
My name is {name}
My name is {name}
- Function definition:Β
function funcName(argument) {}. - Place theΒ argument nameΒ inside theΒ
console.log()Β function. - Call the function with different names (choose them yourself).
- Call theΒ
funcNameΒ function after defining it using theΒfuncName(value)Β syntax.
1234567function myName(name) { console.log("My name is", name); } myName("Ashley"); myName("Ervin"); myName("Mabel");
Everything was clear?
Thanks for your feedback!
SectionΒ 6. ChapterΒ 3