0

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Keno Picker - JS</title>
</head>
<body>
    
    <h2 id = "title"> Keno Picker - JavaScript </h2>
    <ul class="top10"></ul>
    
    <input type="button" onclick="randomFunction()" value="Display">
    
<script type="text/javascript" src="keno.js">
   
    



</script>

</body>
</html>

I am trying to print the result of the "top10" to the webpage. All I get is a print of

" [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]"

This is just a keno picker for me. Figured might be more effective than the quick pick option. I will be making a database of the top10 picked and use that to make choices in the future. But small steps, I am just learning to program.

const N = 80
const arr = Array.from({
    length: N
}, (_, index) => index + 1);
var counts = [];

function randomFunction() {
    function genRandomNumbers() {
        var randomNumbers = Array.apply(null, Array(20)).map(function() {
            return Math.ceil(Math.random() * 80 % 100);
        });
        randomNumbers.forEach(e => counts[e] ? counts[e]++ : counts[e] = 1);
    }
    for (var i = 1; i <= 99; ++i) {
        genRandomNumbers();
    }
}
randomFunction()
counts = new Map([...counts.entries()].sort((a, b) => b[1] - a[1]))
const countsArray = Array.from(counts, ([key, value]) => {
    return {
        [key]: value
    };
});
countsArray.splice(0, 1)
console.log(countsArray)
const top10 = countsArray.slice(0, 10);
console.log(top10)
let top10list = document.querySelector('top10')
let top10items = ""
document.write(top10)
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Maybe try this - https://stackoverflow.com/questions/46141450/create-li-from-loop-through-array-and-display-to-html-as-a-list – the.marolie Oct 25 '22 at 16:18

0 Answers0