Category: Uncategorized

Programming shorthands / tricks 0

Programming shorthands / tricks

  Different ways to track the max value while iterating over different values We can use if, ternary operator or Math.max function as shown below. if (val > max) {   max = val...


How to get the number from the middle of a string

Given the following string extract the number ‘Buy for $199.99’ // 199.99 ‘Gas Price $2.304 per gallon’ // 2.304 We can solve this using slice and, parseFloat(). slice returns the string from the starting...