Bug with final step in function course (JS)


I was just finishing the course on functions in JavaScript, but when I tried to run my code, it told me that it did not print 'Hi, I am Susie' for the name Susie, which was totally bonkers since I looked in the console and it said

Hi, I am Susie

(I copied and pasted that)

Here is my code:

var nameString = function (name) {
    console.log("Hi, I am" + " " + name);



Please, link to your exercise.


Hi the lesson aske you

03.The function returns a string equal to"Hi, I am" + " " + name.
you should put return instead of console.log()


From what you just said, it might expect something like this:

var nameString = function(name) {
  return "Hi, I am " + name;


wow.. Something that i did not think of. I was starting to go crazy here. Maybe because I'm a bit tired and need to rest my mind.. This was helpful.


I bet it didn't feel like a natural way to do it - why wouldn't console.log be inside your nameString() function? My bet is, the author wanted to show the concept of functional programming - your function should always return something, not call another function. Also, side effects should be avoided. There is no accepted definition of a functional language - therefore, we can't say JavaScript is or isn't a functional language, although as you can see, it's possible to apply functional paradigm in JS.


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