From e15e931094db41a9d5e48b41b31458b41116b7b1 Mon Sep 17 00:00:00 2001 From: KrishnaP Date: Tue, 26 Dec 2017 20:49:15 -0800 Subject: [PATCH] Scope --- scope.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/scope.js b/scope.js index e0d709e..7c161f7 100644 --- a/scope.js +++ b/scope.js @@ -2,11 +2,11 @@ var isCookieJarOpen = null; function closeLid() { - /* answer here */ + isCookieJarOpen = false; } function openLid() { - /* answer here */ + isCookieJarOpen = true; } @@ -17,7 +17,7 @@ function outerFunction() { function innerFunction() { var world = 'World'; - return /* answer here */; + return hello + " " + world; } return innerFunction(); } @@ -31,8 +31,8 @@ function addMatrixElements(matrix) { for(var i = 0; i < matrix.length; i++) { /* fix counter variables in the second loop */ - for(var i = 0; i < matrix[i].length; i++) { - result = result + matrix[i][i]; + for(var j = 0; j < matrix[i].length; j++) { + result = result + matrix[i][j]; } } return result; @@ -47,16 +47,17 @@ function sendDataToClient() { handle: 'neo', authenticated: false } - + function authenticateUser(obj, username) { + var userObject = { handle: 'morpheus', authenticated: false }; - if (userObject.handle === username) { - userObject.authenticated = true; - return userObject + if (obj.handle === username) { + obj.authenticated = true; + return obj } else { return userObject }