Search code examples
javascriptgeneratorquote

Trying to build a random quote generator in javascript, but it says my function call value is undefined


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.


Solution

  • 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>