Printing error


I'm currently in the "learn JavaScript", and i'm being introduced to arreys. I do not have a problem, in fact, it's not an error at all, and I can get on, but it just annoys me that when i "run" the script, the brackets from the arrey are displayed too! It's not only the information inside them... Wierd part is, it worked fine at first, but then halfway through all of it changed. What do i do wrong?

var bucketList = ['Exams', 'Get a job', ' Learn to play guitar like James Hetfield'];



if you print the whole array, the square brackets are displayed

if you just want the items in the array, you will need a loop


Ok, thank you for the fast reply


Simply use

yourContainer.innerHTML = JSON.stringify(lineChartData);
If you want something prettier, do

yourContainer.innerHTML = JSON.stringify(lineChartData, null, 4

You can also learn JavaScript here:
But if you just do this in order to debug, then you'd better use the console with console.log(lineChartData).


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.