Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions quiz/arrow.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
<script>
const obj = {
msg: 'Hello World',
hello: function() {
document.getElementById('demo').innerHTML += this.msg;
hello: function() {
document.getElementById('demo').innerText += this.msg;
}
};
window.addEventListener('load', function() {
window.addEventListener('load', () => {
alert(this);
obj.hello();
});
document.getElementById('btn').addEventListener('click', function() {
document.getElementById('btn').addEventListener('click', () => {
alert(this)
obj.hello();
});
</script>
Expand Down
9 changes: 5 additions & 4 deletions quiz/scripts/closure.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
7 changes: 7 additions & 0 deletions quiz/scripts/logger.js
Original file line number Diff line number Diff line change
@@ -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);