My Tuesday JavaScript Mystery

The following code:


    const output = {
        testingSyntax: ['testTag 1', 'testTag2', 'testTag3']

    **((arr) => {**
        const myHtmlTags = [];
        for (let i = 0; i < arr.length; i++) {
            myHtmlTags.push(`<p> this is ${myHtmlTags[i]}</p>`);
        return myHtmlTags



43htmlTagsScripting.html:8 Uncaught TypeError: {(intermediate value)} is not a function
    at 43htmlTagsScripting.html:8

(html:8 line is the bold one)

Any idea what is wrong?

Thanks a lot. <3

You have a missing semicolon in third line, when I added it, it no longer yields an error :wink:

I found similar problem on stack overflow with really nice explanation:

The ECMAScript specification has specific rules for automatic semicolon insertion, however in this case a semicolon isn’t automatically inserted because the parenthesised expression that begins on the next line can be interpreted as an argument list for a function call.

Full post here

1 Like

You’re missing a semicolon for the const output = assignment

edit: oh snap!

1 Like

Thank you! :slight_smile:

Thank you!! :slight_smile: