From cda5580e829ef883b5fdce08f607ca1bf4837b70 Mon Sep 17 00:00:00 2001 From: deshpandeadi1901 Date: Wed, 24 Jan 2024 16:26:25 -0500 Subject: [PATCH] in class work --- quiz/arrow.html | 10 ++++++---- quiz/scripts/closure.js | 9 +++++---- quiz/scripts/logger.js | 7 +++++++ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/quiz/arrow.html b/quiz/arrow.html index fdac020..ad88b5b 100644 --- a/quiz/arrow.html +++ b/quiz/arrow.html @@ -12,14 +12,16 @@ diff --git a/quiz/scripts/closure.js b/quiz/scripts/closure.js index 627414d..93d1e0c 100644 --- a/quiz/scripts/closure.js +++ b/quiz/scripts/closure.js @@ -1,10 +1,11 @@ function setColor(set) { let changeColor = set; - if(changeColor) { - let userColor = document.getElementById('color').value; - document.getElementById('myPara').style.color = userColor; + return () => { + if(changeColor) { + let userColor = document.getElementById('color').value; + document.getElementById('myPara').style.color = userColor; + } } - } window.onload = function() { diff --git a/quiz/scripts/logger.js b/quiz/scripts/logger.js index 5d03eb6..2abe1d9 100644 --- a/quiz/scripts/logger.js +++ b/quiz/scripts/logger.js @@ -1 +1,8 @@ // Define a JavaScript function called logMsg() that can be used to log an error message for any object that contains the property errMsg. +function logMsg() { + console.log(`Error: ${this.errMsg}`); +} +const obj1 = { + errMsg: "error has occured" +} +logMsg.call(obj1); \ No newline at end of file