Place part of an array into a space on Javascript?


#1

-Write another simple function that takes no parameters called "sayName".
-When called, this function should print "Hello, ____!" to the console, where the blank is
equal to the first value in the splitName array from #4. (this first value is my first name-Andrea)
- Call the function. (In our example, "Hello, Tom!" would be printed to the console.)

I am having trouble getting here. This is my code so far but I'm not sure how to do this in a function.

"
function sayName (){
console.log(sayName);
};sayit();

"
I have no idea where to start really. Do I write hello in the function without my name then push in my name? Any help?


#2

Judging by the code entered above, may we assume that you have not really studied JavaScript yet? The instructions above are very straight forward...

Write another simple function that takes no parameters called "sayName".

var sayName = function () {

};

When called, this function should print "Hello, ____!" to the console, where the blank is
equal to the first value in the splitName array from #4. (this first value is my first name-Andrea)

    console.log("Hello, Andrea!");

Call the function. (In our example, "Hello, Tom!" would be printed to the console.)

sayName();

Is this a JavaScript lesson, or is it a quiz question? Please post a link to the exercise, or the quiz question number.


#3

Hey Roy. This is my first week learning any code actually. I actually just figured it out before you posted and it aligns exactly with what you said. I was really just overthinking the problem. I need to start splitting up these questions one by one like you have mentioned to be able to get the correct results. Thank you!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.