This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Using the SoundCloud API Forum

View Course » View Exercise

517 points
2454a7f604f3b535b1bbbe2ef9bea355?s=140&d=retro
Submitted by
matsletten
over 2 years ago

Much seems to be missing from this exercise

I wrote a few versions of what I thought the answer was for this exercise. Each time it accepted my answer, but no comments ever displayed. I'm 100% confident that my answers were not all correct because I even tried a few I knew were wrong, and I was still passed. A couple times, I had a script error warning and I clicked submit, was passed. This is what I ended at. What's frustrating is that there is no way to test if this works becuase we don't have a triggering event that will start showing comments. Bad exercise as it is. Please revise a little.
$(document).ready(function() {
SC.stream('/tracks/293', {
autoPlay: true,
ontimedcomments: function(comment) {
$('#comment').append(html(comment[0].body));
} // add the callback function here
});
});


1 vote

permalink

Yup, it seems like support with this website very limited.
Try using this:

$('#comment').html(comment[0].body);

662 points
Picture
Submitted by
Elvis Petrovich
over 2 years ago


1 vote

permalink

Honestly, I have no freaking idea of what the exercise is asking by callbacks and all that. I have to see the answer and figure out each part of the code by myself on other websites. Sure, this is a great tool to start learning code, but I've been having real issues when it comes to javascript exercises...
I mean, what does "comment[0].body" means?

688 points
Picture
Submitted by
Eryc da Silva
over 2 years ago

1 Comment

Picture Elvis Petrovich over 2 years ago

I suggest you do some research on the subject of callbacks to better understand them. Briefly, a callback function is a function being called from another function as one of its parameters. In this situation the callback function is the function being called from $(document).ready(arg1, arg2, function);

Example:
$(document).ready(parameterX, functionX(){
});
In the example above the callback function is functionX().

The so called callback is named that way because they are supposed to call back or in other words "execute" right after $(document).ready.

And as far as your "what does comment[0].body means?" question. The comment variable is an array that contains other information I'm not aware of, perhaps the comment date or user id?? But in this situation your are accessing the contents of the array comment[0].