Skip to content
Sign upLog in
← Back to Community

Functions and Parameters

Profile icon
mysticlady54

I need help with these questions.

Exercise One:
// Step One: Create a function called 'parametersExercise'.
// Step Two: This function will need to take two parameters, call them 'param1' and 'param2'
// Step Three: The function should console log the second parameter.

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.

I know this is simple but I need help. I am stuck on this one.

Voters
Profile icon
mysticlady54
Comments
hotnewtop
Profile icon
migoyo

I really impressed after read this because of some quality work and informative thoughts . I just wanna say thanks for the writer and wish you all the best for coming!. เว็บแทงบอลที่ดีที่สุด

Profile icon
LeviHarrison

What language is this? Assuming it's in Javascript, because of the 'console log' in your post here you go:

function parametersExercise(param1, param2) {
console.log(param2);
}

myName = "John Doe";

sayMyName(myName)

Profile icon
LeviHarrison

I should probably also explain how this works. Inside the parathas next to the name of the function, you can specify parameters, or for simplicity, variables. These variables can only be used inside the function. The way you set those variables is by specifying their values when you call the function. So, when I call the function parametersExercise and in parenthesis specify two pieces of text, the function will run with param1 set to the first piece of text and param2 set to the second. If this is hard to understand, here is an example:

//Here is the Function:
function parametersExercise(param1, param2) {
console.log(param2);
}

//Now I call the function:
parametersExercise("Hello", "Goodbye");

//param1 will be set to "Hello", param2 will be set to "Goodbye", Goodbye will be printed in the console

As you can see the order matters. You can also specify a variable when you call a function. When you do that the parameter will be set to the value of the variable. Hope this helps.

Profile icon
Vandesm14

What have you tried so far?

Profile icon
eco27

@Vandesm14
deleted sorry

Profile icon
Vandesm14

@MrEconomical
You mean the post? It's still up.