Skip to content

Instantly share code, notes, and snippets.

@sharmaabhinav
Created March 7, 2021 06:35
Show Gist options
  • Save sharmaabhinav/5686997f3d94cb92888d5e14adb31833 to your computer and use it in GitHub Desktop.
Save sharmaabhinav/5686997f3d94cb92888d5e14adb31833 to your computer and use it in GitHub Desktop.
Sample APIs problems
Array map
const arr = [2,3,4,5]
arr.map((el) => 2 * el)
Output = [4,6,8,10]
String repeat
const city = “ajmer”
city.repeat(5)
Output = “ajmerajmerajmerajmerajmer”
Array reduce
const arr = [2,3,4,5]
arr.reduce((sum, el) => sum + el)
Output = 14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment