From 81e965b92a56db485104c6cbe8fa1b818abf4501 Mon Sep 17 00:00:00 2001 From: Abhisek Pattnaik Date: Sat, 26 Dec 2015 06:48:38 +0530 Subject: [PATCH] Local Scope and Functions --- .../basic-javascript.json | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/seed/challenges/01-front-end-development-certification/basic-javascript.json b/seed/challenges/01-front-end-development-certification/basic-javascript.json index 995b730772f..ebe63ec6cf2 100644 --- a/seed/challenges/01-front-end-development-certification/basic-javascript.json +++ b/seed/challenges/01-front-end-development-certification/basic-javascript.json @@ -1969,30 +1969,47 @@ "id": "56533eb9ac21ba0edf2244bf", "title": "Local Scope and Functions", "description": [ - "Variables which are declared within a function, as well as function parameters are local. Thos means they are only visible within that function. ", + "Variables which are declared within a function, as well as the function parameters have local scope. That means, they are only visible within that function. ", "Here is a function myTest with a local variable called loc.", - "
function myTest() {
var local1 = \"foo\";
console.log(local1);
}
myTest(); // \"foo\"
console.log(local1); // \"undefined\"
", - "local1 is not defined outside of the function.", + "
function myTest() {
var loc = \"foo\";
console.log(loc);
}
myTest(); // \"foo\"
console.log(loc); // \"undefined\"
", + "loc is not defined outside of the function.", "

Instructions

", "Declare a local variable myVar inside myFunction" ], "releasedOn": "11/27/2015", "tests": [ - "assert(1===1, 'message: message here');" + "" ], "challengeSeed": [ "function myFunction() {", " ", " console.log(myVar);", "}", + "myFunction();", "", + "// run and check the console ", + "// myVar is not defined outside of myFunction", "console.log(myVar);", + "", + "// now remove the console.log line to pass the test", "" ], "tail": [ "" ], "solutions": [ + "function myFunction() {", + " var myVar;", + " console.log(myVar);", + "}", + "myFunction();", + "", + "// run and check the console ", + "// myVar is not defined outside of myFunction", + "", + "", + "// now remove the console.log line to pass the test", + "", "" ], "type": "waypoint",