-2

So, I'm trying to build a random quote generator in HTML/JavaScript. Well, more of a random Japanese Emoticon Generator.

I've had no problems up until recently, where it keeps saying that my newEmoticon function isn't defined.

Here is the code -

<html>
    <head>
    <style>
        <meta charset="utf-8">
        <title> Japanese Emoticon Generator </title>
        <meta name= “description” content=“A Japanese emoticon generator for all your Japanese emoticon needs.”> 
    </style>
    </head>
    <body>
    <h1>Japanese Emoticon Generator </title>
    <br>
    <button onclick="newEmoticon()">Generate!</button> 
    <div id="emoticonDisplay">
    </div>
    <h3>All emoticons credit of <a href="http://japaneseemoticons.me/">japaneseemoticons.me</a> and <a href="https://textfac.es/">textfac.es</a></h3>

<script>
 var emoticons = [

't(〃⊙౪ ∩=)/',   '-(๑☆‿ ☆#)ᕗ',   '((☆^⌓ ^☆)╭',
'((o⊙Σ ⊙。)m',   '「(;´Σ `〃)ヘ',   '「(#Φ益 Φo)∩',
'「(=>o≦=)ノ',    '~(。☉︵ ಠ@)>',   '~(๑ñ﹏ ⊙☆)ノ',
'⊂(o•ิ▂ ñ*)づ',  '┗( ●-﹏ `。)づ',  '╭ (oㅇ‿ o#)ᕗ
╮', '(☆-_ ⊙;)ゞ',    '╰(๑^⌓ ^=)ᕗ',   'ヾ (;・﹏ •̀☆)b
ヾ', '(✿>﹏ ⊙〃)ノ',    'ヽ(♡≧m´。)っ',    'm(★⊙¬ ㅇ ●)ლ',
'O(*@д o#)づ',   'O(o^O `;)人',   'Σ(@°xº♡)/',
'Σ(♡@﹏ @☆)ノ”',  'Σ(๑+⌓ o。)シ',   'φ( ●⌒へ ⌒〃)o',
'ψ(๑∩⌓ ∩ ●)y',  'щ (*ㅇ△ Φ☆)ノ',  'ლ (#`ロ^;)>',
'ᕙ (;`⊥ ^★)┐',  'ᕙ (✿⊙へ ⊙〃)',   'ᕙ (❁^д ^*)っ',
'ᕦ(;*Σ ⌒❁)ᕗ',   'へ( ●`ㅅ `☆)ლ', 'へ(。•ิ‿ -〃)',
'┗(•̀へ •́ ╮ )',  '╭( ✖_✖ )╮', '( ͡° ͜ʖ ͡°)',    '∠( ᐛ 」∠)_  ',
 '(゚⊿゚)', 'ᕕ( ᐛ )ᕗ',    '_へ__(‾◡◝ )>',  '( ᐛ )و',
'( ◞・౪・)    ', '¯\_༼ ି ~ ି ༽_/¯',   '¯\_༼ ಥ ‿ ಥ ༽_/¯',
'¯\_(⊙_ʖ⊙)_/¯', '¯\_| ✖ 〜 ✖ |_/¯',  '¯\_▐ ☯ ︿ ☯ ▐_/¯',
'¯\_╏ ՞ ︿ ՞ ╏_/¯    ', '¯\_(⊙︿⊙)_/¯ ', '¯\_ȌᴥȌ_/¯',
'¯\_ʘᗜʘ_/¯',    '¯\_ȌᴥȌ_/¯'     , '( ;`ヘ´)', '((( ̄へ ̄井)',
 '(`へ´*)ノ', '( ̄へ ̄)',   '(。-`へ´-。)',   'ε-(‘ヘ´○)┓',
'(≧ヘ≦ )',  'ρ( ̄ヘ ̄ メ)',    '(*`・へ・´*)',
'(((0へ0)', '(*`へ´*) 彡3',  '(`へ′)'
];
//More will be gradually added in the future. Be patient.

function newEmoticon() {
    var random = Math.floor(Math.random() * (emoticons.length));
    document.getElementById('emoticonDisplay').innerHTML = emoticons[random];
}

 </script>
</body>
</html>

I've tried google searches and redoing the code, but I haven't gotten any results.

Thanks.

Trent
  • 41
  • 5
  • Welcome to Stackoverflow. Your code should be posted **here**. This site has ample facilities for hosting source code directly, and cutting ties to external sites is an explicit goal. – Pointy Sep 22 '17 at 20:52
  • Edited it. Thanks for telling me! – Trent Sep 22 '17 at 20:54
  • Your actual problem is that your list of emoticons has syntax errors in it. That error you're (probably) seeing about an "unterminated string literal" is the reason that your function isn't defined. – Pointy Sep 22 '17 at 21:02

1 Answers1

2

You have an error on line 23, use the browsers developer tools to look for things like this in the future, try this

    <html>
    <head>
    <style>
        <meta charset="utf-8">
        <title> Japanese Emoticon Generator </title>
        <meta name= “description” content=“A Japanese emoticon generator for all your Japanese emoticon needs.”> 
    </style>
    </head>
    <body>
    <h1>Japanese Emoticon Generator </title>
    <br>
    <button onclick="newEmoticon()">Generate!</button> 
    <div id="emoticonDisplay">
    </div>
    <h3>All emoticons credit of <a href="http://japaneseemoticons.me/">japaneseemoticons.me</a> and <a href="https://textfac.es/">textfac.es</a></h3>
<script>
 var emoticons = [

't(〃⊙౪ ∩=)/',   '-(๑☆‿ ☆#)ᕗ',   '((☆^⌓ ^☆)╭',
'((o⊙Σ ⊙。)m',   '「(;´Σ `〃)ヘ',   '「(#Φ益 Φo)∩',
'「(=>o≦=)ノ',    '~(。☉︵ ಠ@)>',   '~(๑ñ﹏ ⊙☆)ノ',
'⊂(o•ิ▂ ñ*)づ',  '┗( ●-﹏ `。)づ',  '╭ (oㅇ‿ o#)ᕗ ╮', 
'(☆-_ ⊙;)ゞ',    '╰(๑^⌓ ^=)ᕗ',   'ヾ (;・﹏ •̀☆)b ヾ', 
'(✿>﹏ ⊙〃)ノ',    'ヽ(♡≧m´。)っ',    'm(★⊙¬ ㅇ ●)ლ',
'O(*@д o#)づ',   'O(o^O `;)人',   'Σ(@°xº♡)/',
'Σ(♡@﹏ @☆)ノ”',  'Σ(๑+⌓ o。)シ',   'φ( ●⌒へ ⌒〃)o',
'ψ(๑∩⌓ ∩ ●)y',  'щ (*ㅇ△ Φ☆)ノ',  'ლ (#`ロ^;)>',
'ᕙ (;`⊥ ^★)┐',  'ᕙ (✿⊙へ ⊙〃)',   'ᕙ (❁^д ^*)っ',
'ᕦ(;*Σ ⌒❁)ᕗ',   'へ( ●`ㅅ `☆)ლ', 'へ(。•ิ‿ -〃)',
'┗(•̀へ •́ ╮ )',  '╭( ✖_✖ )╮', '( ͡° ͜ʖ ͡°)',    '∠( ᐛ 」∠)_  ',
 '(゚⊿゚)', 'ᕕ( ᐛ )ᕗ',    '_へ__(‾◡◝ )>',  '( ᐛ )و',
'( ◞・౪・)    ', '¯\_༼ ି ~ ି ༽_/¯',   '¯\_༼ ಥ ‿ ಥ ༽_/¯',
'¯\_(⊙_ʖ⊙)_/¯', '¯\_| ✖ 〜 ✖ |_/¯',  '¯\_▐ ☯ ︿ ☯ ▐_/¯',
'¯\_╏ ՞ ︿ ՞ ╏_/¯    ', '¯\_(⊙︿⊙)_/¯ ', '¯\_ȌᴥȌ_/¯',
'¯\_ʘᗜʘ_/¯',    '¯\_ȌᴥȌ_/¯'     , '( ;`ヘ´)', '((( ̄へ ̄井)',
 '(`へ´*)ノ', '( ̄へ ̄)',   '(。-`へ´-。)',   'ε-(‘ヘ´○)┓',
'(≧ヘ≦ )',  'ρ( ̄ヘ ̄ メ)',    '(*`・へ・´*)',
'(((0へ0)', '(*`へ´*) 彡3',  '(`へ′)'
];
//More will be gradually added in the future. Be patient.

function newEmoticon() {
    var random = Math.floor(Math.random() * (emoticons.length));
    document.getElementById('emoticonDisplay').innerHTML = emoticons[random];
}

 </script>
</body>
</html>
James
  • 926
  • 1
  • 8
  • 24