HTML example code:-
<!DOCTYPE HTML> <html> <body> <script> var answers = ["A", "B", "C","D","E"]; var randomAnswer = answers[Math.floor(Math.random() * answers.length)]; console.log(randomAnswer); </script> </body> </html>
Output: You output may be not same because this code get random elements.
Do comment if you have any doubts and suggestions on this JS Array topic.
Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.