You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 19, 2024. It is now read-only.
We use the inline code suite in the learning platform for Bloc, and we're running into an issue trying to teach DOM manipulation in javascript. We define a simple DOM in the HTML tab, and attempting to iterate over the list items in an unordered list is throwing a TypeError.
JS tab:
var x = document.getElementById("list").childElementCount;
console.log(x, typeof x);
var num = 4;
console.log(num, typeof num);
for (i = 0; i < x; i++) {
console.log(i);
}
TypeError: Cannot convert object to primitive value
Screencap of issue:
If we update the JS tab to iterate until an explicitly defined integer on line 6, we can iterate correctly, with no error:
var x = document.getElementById("list").childElementCount;
console.log(x, typeof x);
var num = 4;
console.log(num, typeof num);
for (i = 0; i < num; i++) {
console.log(i);
}
We use the inline code suite in the learning platform for Bloc, and we're running into an issue trying to teach DOM manipulation in javascript. We define a simple DOM in the HTML tab, and attempting to iterate over the list items in an unordered list is throwing a TypeError.
JS tab:
HTML tab:
When running, the console prints this error:
Screencap of issue:

If we update the JS tab to iterate until an explicitly defined integer on line 6, we can iterate correctly, with no error:
Working results:
