Callback function

I am getting the following error after I console.log the following function statements; please help! What am I doing wrong.

let sleepingPeriod = function(dreaming, snoring, sleepTime){
    if (sleepTime ==='nightTime'){
        return snoring;
    } else if (sleepTime ==='dayTime'){
        return dreaming;
console.log(sleepTime === "nightTime");

VM1838:1 Uncaught SyntaxError: Identifier ‘sleepingTime’ has already been declared
at :1:1

Hey @java9898360319, welcome to the forums!

Can you send us the link to the exercise so we can see what you’re supposed to do? Thanks!

While we’re waiting for that, here is a couple of bugs in the mean time:

It looks like you’re using the comparison operator here, in a place you’re not really supposed to.

Parameters are supposed to be used like this:

const example = function(name) => {
  return name

// Outputs Steven

The above function will set name equal to Steven because that is the way parameters are used.

The reason what you did was wrong is because you used a comparison operator in an attempt to assign the parameter to a value (I assume this is what you were trying to do). === is a comparison operator, used in if/else statements and the like so to use it here would be incorrect.

Another bug is that in your function, you had three parameters needed, but you only have one.

dreaming and snoring are not mentioned in the function callback line.

To fix this, you would have to provide parameter values in the line where you call the function.

Here’s an example:

const example =  function(greeting, name, country) {
  return greeting + "! My name is " + name + " and I come from " + country;

example("Hi", "Steven", " the USA!");

// Outputs, Hi! My name is Steven and I come from the USA!

Try those out and see if they fix your bugs.

Hope this helps!