How to console.log a function

<%= @topic_view.topic.title %>
<%= @topic_view.topic.average_rating %> <%= @topic_view.topic.posts.count { |p| !!p.custom_fields['rating'] } %>

I wonder why when I put `function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {

var result = "The " + " " + myAdjective + " " + myNoun + " " + myVerb + " " + myAdverb + “.”;

return result;
}

wordBlanks(“dog”, “big”, “ran”, “quickly”);

console.log(wordBlanks());`

the console does not print out “The big dog ran quickly.”

Because the call to wordBlanks in console.log(wordBlanks()); doesn’t have the arguments “dog”, “big”, “ran”, and “quickly”.

2 Likes

@ArielLeslie thank you for that clarification. I still wonder how to put that right though could you help me with that?

create a variable and store the function in that variable. then console.log the variable

1 Like

put 4 strings in the parenthesis

console.log(wordBlanks("noun", "adjective", "verb", "adverb"));

or inside the function add console.log(result) before the return result line

2 Likes