My JS code won't working don't know where did i made mistake it seems all ok to me

here is my JS Code

  function getQuote()
    var quotes=["shani","baba","Me","I'm"];
    var authors=["A1","A2","A3"];
    var randomNum=math.floor((math.random()*quotes.length));
    var randomQuote=quotes[randomNum];
    var randomAuthor=authors[randomNum];

Here is my HTML

<div class="container text-center">
  <h1>Random Quote Generator</h1>
  <button class="mybutton" type=submit> New Quote </button>
<div class="quotes">
  <span class="quote"> Hello World !! </span>
  <span class="author">The World</span>


Thanks in Advance

There are some errors in your code. Here an working example of your refactored code. Take a closer look at the commas you are using:

var quotes=[“shani”,“baba”,“Me”,“I’m”];
var authors=[“A1”,“A2”,“A3”];

and this ones:

  var quotes = ["shani", "baba", "Me", "I’m"];
  var authors = ["A1", "A2", "A3"];

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


First question for you: Are you getting any errors showing in the browser’s console (Ctrl+Shft+J in Chrome)? If so, see if you can fix those first.

One error I see right off is the following:

JavaScript is case-sensitive, so math is not the same as Math. Double check what case your built-in function calls should be.

1 Like

Got it. it was a case-sensitive error and a spell error i.e math.randon replaced with Math.random :slight_smile:
thank you for giving me your time.

it wasn’t issue of commas it was mis spell and case-sensitive issue.

You can get rid of your ‘type=submit’ from your button html too