Skip to content

Instantly share code, notes, and snippets.

@iHani
iHani / reduce.js
Last active September 25, 2019 20:34
Array.reduce() example - JavaScript
/*
* Array.reducer()
* "The reduce() method executes a reducer function (that you provide) on each
* element of the array, resulting in a single output value" - MDN Docs
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce
*/
const arr = [1, 10, 4];
// get the sum of all elements in the array
@iHani
iHani / englishinize.js
Last active March 6, 2024 03:28
Converts Arabic numbers chars to normal English numbers #JavaScript
/**
* Converts Arabic numeric chars to English.
* @param {Number} number - The Arabic number to be converted to English number.
* Thanks to whomever I stole this code from on the web a while ago.
* Michael Scott: It's whoever, not whomever.
* Ryan: It's whomever.
* Michael Scott: No, whomever is never acutally right.
* Jim Halpert: Nope, sometimes it's right.
* Creed: Michael is right. It's a made up word used to trick students-
*/