Printing error


#1


https://www.codecademy.com/courses/learn-javascript/lessons/arrays/exercises/create-an-array?action=lesson_resume&link_content_target=interstitial_lesson

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'];

console.log(bucketList);


#2

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


#3

Ok, thank you for the fast reply


#4

Simply use

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

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

);
Demonstration
You can also learn JavaScript here: https://hackr.io/tutorials/learn-javascript
But if you just do this in order to debug, then you'd better use the console with console.log(lineChartData).


#5

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