Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialjason limmm
8,009 Pointsproblem planning how should random coin game be coded
i wanna make it so that after the user inputs the rows and columns they'll get a random side of a coin in their respective grids if it is 1 then it's Heads, if it's 2 then it's Tails.
i'm having problems with planning out how my code should be written
//defining variables for convenience's sake
const rows = document.querySelector('#rows').value;
const columns = document.querySelector('#columns').value;
const submitbutton = document.querySelector('#coingamesubmit');
// variable(s) for function
const randomnumber = Math.floor(Math.random()*2)+1;
const p = ' ';
function headsortailsdecider(randomnumber) {
if (randomnumber==1){
p.innerHTML = 'H'
}else if (randomnumber == 2){
p.innerHTML = 'T'
}
}
submitbutton.addEventListener('click', ()=>{
//i'm stuck here
});
here's my pug too
h1 Coin Game!
h2 How many rows and columns you want?
form
div#rows
label#rowlabel(for='rows') Rows:
input#rows(type='text')
div#columns
label#columnlabel(for='columns') Columns:
input#columns(type='text')
button#coingamesubmit(type='submit') Submit
script(src='static/js/coingamebehavior.js' type='text/js')