This is a bug in JSBin's loop protection.
When you use this code (JSBin link):
let myTodos = {
day: "Monday",
meetings: 0,
meetDone: 0,
}
let addMeeting = function(todo, meet = 0) {
todo.meetings = todo.meetings + meet;
}
let meetDone = function (todo, meet = 0) {
todo.meetDone = todo.meetDone - meet;
}
let resetDay = function (todo) {
todo.meetings = 0;
todo.meetDone = 0;
}
let getSummaryOfDay = function (todo) {
let meetleft = todo.meetings + todo.meetDone;
return `You have ${meetleft} meetings for today.!`;
}
addMeeting(myTodos, 4);
addMeeting(myTodos, 2);
meetDone(myTodos, 5);
console.log(getSummaryOfDay(myTodos));
console.log (myTodos);
JSBin produces the following document that will be executed:
<!DOCTYPE html>
<html>
<head>
<meta charset=\"utf-8\">
<meta name=\"viewport\" content=\"width=device-width\">
<title>JS Bin</title>
<style id=\"jsbin-css\">
</style>
</head>
<body>
<script>try {let myTodos = {
day: \"Monday\",
meetings: 0,
meetDone: 0,
}
let addMeeting = function(todo, meet = 0) {
todo.meetings = todo.meetings + meet;
}
let meetDone = function (todo, meet = 0) {
todo.meetDone = todo.meetDone - meet;
}
let resetDay = function (todo) {
todo.meetings = 0;
todo.meetDone = 0;
}
let getSummaryOfDay = function (todo) {
let meetleft = todo.meetings + todo.meetDone;
{
if (window.runnerWindow.protect.prote{;window.runnerWindow.protect.protect({ line: 23, reset: true }); ct({ line: 23 })) break;
return `You have ${meetleft} meetings for today.!`;
}}
}
addMeeting(myTodos, 4);
addMeeting(myTodos, 2);
meetDone(myTodos, 5);
window.runnerWindow.proxyConsole.log(getSummaryOfDay(myTodos));
window.runnerWindow.proxyConsole.log (myTodos);
} catch (error) { throw error; }
//# sourceURL=xibavicide.js
</script>
</body>
</html>
Note how the template literal is wrapped in the protection code and now it's not syntactically correct.
Presumably, the protection is there to stop infinite loops.
If you just remove for
(JSBin link) then you don't trigger the protection and the document produced is syntactically correct:
<!DOCTYPE html>
<html>
<head>
<meta charset=\"utf-8\">
<meta name=\"viewport\" content=\"width=device-width\">
<title>JS Bin</title>
<style id=\"jsbin-css\">
</style>
</head>
<body>
<script>try {let myTodos = {
day: \"Monday\",
meetings: 0,
meetDone: 0,
}
let addMeeting = function(todo, meet = 0) {
todo.meetings = todo.meetings + meet;
}
let meetDone = function (todo, meet = 0) {
todo.meetDone = todo.meetDone - meet;
}
let resetDay = function (todo) {
todo.meetings = 0;
todo.meetDone = 0;
}
let getSummaryOfDay = function (todo) {
let meetleft = todo.meetings + todo.meetDone;
return `You have ${meetleft} meetings today.!`;
}
addMeeting(myTodos, 4);
addMeeting(myTodos, 2);
meetDone(myTodos, 5);
window.runnerWindow.proxyConsole.log(getSummaryOfDay(myTodos));
window.runnerWindow.proxyConsole.log (myTodos);
} catch (error) { throw error; }
//# sourceURL=roqosiyasa.js
</script>
</body>
</html>
You can use a workaround suggested in the bug - adding a // noprotect
comment anywhere in the JavaScript area will stop the loop protection from triggering. JSBin link