## 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...

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...

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...

Recursive : To delete all the nodes, you will have to visit all the nodes. There are three ways to traverse the binary tree : Post order Pre order In order. To delete all...

Problem : Given a JSON data structure with key representing age and value representing the number of people with that age. For example, { 25: 55, 26: 45, 27: 10, 28: 20, 30: 1,...