// Convert a value to a number
Number('42') // β 42
Number(true) // β 1
Number(false) // β 0
Number('') // β 0Use the Number() function to explicitly convert a value to a numeric type, which is more predictable than implicit coercion.
Number(value) converts a value to a number primitive.
Challenge: Implement strToNum(str) that converts a string to a number using Number().
strToNum('42') // β 42
strToNum('3.14') // β 3.14