Ask coding questions

← Back to all posts
JS Assignment 7: Arguments and Parameters
skudeva (16)

Hi everyone,
What am I doing wrong in this exercise?

// Exercise Two:
// Step One create a variable called 'myName' and assign it the a string of your name.
// Step Two: Call the function called "sayMyName",passing the 'myName' variable as it's only argument.
// NOTE: You do NOT need to create the function (sayMyName), doing so will break the test.
// It has been created for you.
// Exercise Two:
// Step One create a variable called 'myName' and assign it the a string of your name.
// Step Two: Call the function called "sayMyName",passing the 'myName' variable as it's only argument.
// NOTE: You do NOT need to create the function (sayMyName), doing so will break the test.
// It has been created for you.

let myName = "Stefka";
sayMyName ('myName');

Answered by heyitsmarcus (287) [earned 5 cycles]
View Answer
Commentshotnewtop
heyitsmarcus (287)

When you're passing in variables as a parameter, do not enclose them in quotes. When you pass in 'myName' (with the quotes around it), you are passing in a string with the literal value of myName.

What you want is the value that is inside of myName, so you only need to pass in the variable:

let myName = "Stefka";
sayMyName(myName);

This way, the function sayMyName will use the value inside of myName (which is Stefka) instead of using the literal string 'myName' which would just result in it calling you myName instead of Stefka.

Please accept my answer if it helped you with your problem.