Js: Scope and the return Statement
Paultheriault (2)

Not sure how to get this code to run without errors. Primarily, I have been receiving an error that says my variable (? I think) is undefined or that is already defined (? I am so stuck). Any hints or pointers would be greatly appreciated.

// Example Code: Reference this code for the next Exercise
let school = 'Lambda';
let className = 'Intro to Web Dev'

function nameMySchool(){
let className = "Web Development Fundamentals"
console.log(school);
}

nameMySchool();
console.log(className);
// Do not change any code above this line!

// Exercise One:
// Part One: Create a variable called 'inFunction' and
// assign it to the value that will be logged
// on line 7.
var infunction = (school, className);

// Part Two: Create a variable called 'outsideFunction' and
// assign it to the value that will be logged on
// line 11.

// Exercise Two:
// Create a Function called 'multipliesTwoNumbers'. It will take two parameters
// call these parameters 'num1' and 'num2'. Return the two parameters multiplied together.

// Exercise Three:
// Create a function called 'sayMyName'. It will take one parameter. Call this
// parameter 'myName'. Return the phrase "Hello, my name is " and the myName parameter.
// eg: if name is 'Dan' it should return the string: 'Hello, my name is Dan'.

You are viewing a single comment. View All
Answered by vedprad1 (731) [earned 5 cycles]
View Answer