This is what I came up with but it doesn't work. I don't get an output.
Javascript.js
function randomnamegen() {
var names = ["Mango", "Pul", "Bat", "Tim", "Mh", "Hei"];
var namein = names(Math.floor((Math.random() * 5) + 0));
document.getElementById("name").innerHTML = namein;
}
index.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Cherry Cheese Danish</title>
</head>
<body>
<button type="button" onclick="randomnamegen()">Click Me!</button>
<p id="name"></p>
<script src="JavaScript.js"></script>
</body>
</html>
I get an Uncaught TypeError: object is not a function JavaScript.js:3 in google chrome console.
names[...];