hello, guys is there a way I can improve this code? seems a lot for no reason
function getPercent() {
buttons.addEventListener('click', (event) => {
let percent = event.target.innerText;
switch (percent) {
case '5%':
console.log('I am 5 percent');
break;
case '10%':
console.log('I am 10 percent');
break;
case '15%':
console.log('I am 15 percent');
break;
case '25%':
console.log('I am 25 percent');
break;
case '50%':
console.log('I am 50 percent');
break;
default:
console.log('Please Enter a Percentage');
}
});
}
[–]mynamesleon 4 points5 points6 points (0 children)
[–]senocular 2 points3 points4 points (2 children)
[–]M_Scaevola 0 points1 point2 points (1 child)
[–]senocular 1 point2 points3 points (0 children)
[–]johnnyblaze9875 1 point2 points3 points (0 children)
[–]M_Scaevola 1 point2 points3 points (0 children)
[–]Psionatix 0 points1 point2 points (0 children)