I have a speed typing game. I also have a form with 3 radio buttons and i want to select the level of the game based on the selected radio button. How can i do that?
I've tried with document.querySelector('input[name="genderS"]:checked').value;
this code here. But it doesn't worked
const levels = {
easy: 5,
medium: 3,
hard: 1
};
let easyChecked = document.querySelector('#radio-easy').checked;
let mediumChecked = document.querySelector('#radio-medium').checked;
let hardChecked = document.querySelector('#radio-hard').checked;
var currentLevel = levels.medium;
let time = currentLevel;
let score = 0;
let isPlaying;
// To change level
function isChecked() {
}
I expect currentLevel variable to be changed based on the radio buttons.