beginner-javascript icon indicating copy to clipboard operation
beginner-javascript copied to clipboard

Async Typer UI - getRandomBetween() not behaving as expected because it's being called with strings

Open nmpeterson opened this issue 2 years ago • 1 comments
trafficstars

https://github.com/wesbos/beginner-javascript/blob/ab2cb26365378b015e3ed3a630771baf3da261fa/exercises/73%20-%20Async%20Typer/scripts-FINISHED.js#L31

When passed to getRandomBetween() here, typeMin and typeMax are still strings taken directly from el.dataset. Not sure exactly how the function is treating these numeric strings under the hood, but it's not parsing them as ints:

image

nmpeterson avatar Jan 17 '23 23:01 nmpeterson

Olá, é provável que na linha 27, onde:

const { typeMin, typeMax } = el.dataset;

O el.dataset, esteja passando os valores em string. tente adicionar nessa linha de código o parseInt:

const { typeMin, typeMax } = parseInt(el.dataset);

Talvez consiga converter esses valores em numbers.

AlvaroCastroC avatar Nov 28 '23 21:11 AlvaroCastroC