aura

joined 1 week ago
[–] aura@lemmy.dbzer0.com 10 points 5 days ago (1 children)

it's not exactly the formula i posted but the principle is kinda the same

if u see it like this:

let min = 1
let max = 100
let random = Math.floor(Math.random() * (max - min + 1)) + min

the diff is that it's inclusive of max (bc of +1) and it always returns an integer (bc of Math.floor)

btw not defending this abomination of a man in javascript language or anything lol

[–] aura@lemmy.dbzer0.com 12 points 5 days ago (4 children)

that is common usage to get a random number between two values in JS. as unintuitive as it looks it's just more maintainable like that, the code was prolly just minified

Math.random() * (max - min) + min

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random#getting_a_random_integer_between_two_values

[–] aura@lemmy.dbzer0.com 8 points 1 week ago

OP might easily find a used thinkpad t14/t14s for less than €650, up to gen 4.

when choosing the thinkpad generation, it's often a trade-off between CPU performance (newer gen) and RAM upgradability (older gen). some gen 3+ models use soldered memory, but you get better CPU performance ;) check carefully