How do I fix this.  I have been working on it for days.?

function exerciseOne(){

// On line 3, create a variable named 'myName' and assign it a string containing your name:

var firstName = 'Ruth'; let lastName = 'Taylor';

}

// Please write answer above

 return;

function exerciseTwo(){

// On line 11, create a variable named 'tripsAroundTheSun' and assign your age as a number:

var tripsAroundTheSun; const answer=65;

// Please write answer above

 return;

}

function exerciseThree(){

// On line 19, create a variable named 'pineappleOnPizza' and assign it a Boolean of whether or not you think pineapple belongs on pizza:

  var pineappleOnPizza;

// Please write answer above

 return;

}

I get this when I run it.

Native Browser JavaScript

SyntaxError: 'return' outside of function (7:1)

   

4 Answers

Relevance
  • Anonymous
    4 weeks ago

    function exerciseOne(){

    // On line 3, create a variable named 'myName' and assign it a string containing your name:

     var myName = 'Ruth Taylor';

    // Please write answer above

     return;

    }

    function exerciseTwo(){

    // On line 11, create a variable named 'tripsAroundTheSun' and assign your age as a number:

     var tripsAroundTheSun = 65;

    // Please write answer above

     return;

    }

    function exerciseThree(){

    // On line 19, create a variable named 'pineappleOnPizza' and assign it a Boolean of whether or not you think pineapple belongs on pizza:

     var pineappleOnPizza = true;

    // Please write answer above

     return;

    }

  • 4 weeks ago

    I have no idea at all

  • Chris
    Lv 7
    4 weeks ago

    Something like this I guess: https://jsfiddle.net/khrismuc/t754xawq/

    The function body is enclosed by { and }. You can only "return" from inside a function.

  • 4 weeks ago

    To fix that error, move the first } line to *after* the return statement.  The {} braces must enclose the entire function body.

Still have questions? Get answers by asking now.