Search code examples
javascriptjquerysyntaxflickr

Why do I get a syntax error on the semicolon?


This bit of code does not produce any errors:

//if the image has tags
if(data.photo.tags.tag != '') {

    //create an empty array to contain all the tags
    var tagsArr = new Array();

    //for each tag, run this function
    $.each(data.photo.tags.tag, function(j, item){

        //push each tag into the empty 'tagsArr' created above
        tagsArr.push('<a href="http://www.flickr.com/photos/tags/' + item._content + '">' + item.raw + '</a>');

    });

    //turn the tags array into a string variable
    //var tags = tagsArr.join(' ');
}

But If I change the tags array push line to:

//push each tag into the empty 'tagsArr' created above
    tagsArr.push( + item.raw + );                                    
});

Then I get a syntax error on the semicolon. What I'm trying to do is to remove the tagged links and just return raw links.

Thoughts & Thanks!


Solution

  • if you just want the output the item.raw value do:

    tagsArr.push(item.raw);