Course Content
Introduction to JavaScript
Introduction to JavaScript
Challenge: My Name
Task
Implement a function to output a sentence:
- Name the function
myName
. - The function should accept one argument,
name
. - The
myName
function body should contain aconsole.log()
statement that prints the sentence"My name is {name}"
. - Call the
myName
function three times with different names.
function ___(___) { console.log("My name is", ___); }; myName("___"); myName("___"); myName("___");
The output should be:
- 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 thefuncName(value)
syntax.
function myName(name) { console.log("My name is", name); } myName("Ashley"); myName("Ervin"); myName("Mabel");
Thanks for your feedback!