Getting the below error code in JS Bin when I am trying to run the following code, am I doing anything wrong??
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);
And the error that I am getting in JS Bin is as follows.
"error"
"SyntaxError: Unexpected token '{'
at https://static.jsbin.com/js/prod/runner-4.1.7.min.js:1:13924
at https://static.jsbin.com/js/prod/runner-4.1.7.min.js:1:10866"
This is a bug in JSBin's loop protection.
When you use this code (JSBin link):
JSBin produces the following document that will be executed:
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:You can use a workaround suggested in the bug - adding a
// noprotectcomment anywhere in the JavaScript area will stop the loop protection from triggering. JSBin link