Attempt these 20 simple problems today to make your "logic building" strong.
⇩
1️⃣ Recursion
✪ Print a pattern (eg. triangle of numbers/asterisks)
✪ Sum of digits of a number
✪ Sum of natural numbers
✪ Factorial of a number
✪ Print Fibonacci Sequence
✪ Check if a string/number is palindrome
✪ Reverse a string/number/array
2️⃣ Divide and Conquer
✪ Find exponential of a number
✪ Search element in a sorted array/matrix
✪ Floor in a sorted array
✪ Merge 2 sorted arrays to create another sorted array
✪ Find median of 2 sorted arrays (same & different size)
✪ kth element in 2 sorted arrays
Operations evaluating to NaN
↳ Conversion to a Number
↳ Parsing to a Number
↳ Indeterminate Forms
↳ Math functions
Let's explore.
⇩
1️⃣ Conversion to a Number
Conversion happens in 2 ways in JavaScript
↳ Implicit Conversion
Operations where a number is expected
Example: Unary +, Binary - etc
↳ Explicit Conversion
Using Number() or, new Number()
Let's see what are evaluated to NaN
2️⃣ Parsing to a Number
There are 2 number parsing methods
↳ parseInt
↳ parseFloat
The process is,
✪ Leading and trailing spaces are ignored
✪ If the first character cannot be converted to a number, NaN is returned
✪ Only the first number found is returned