From 99504b1b9cdb35f53289de6b3c0115accddbe291 Mon Sep 17 00:00:00 2001 From: Yusof Bandar Date: Mon, 18 Feb 2019 14:23:47 +0000 Subject: [PATCH 01/11] Create map-number-range.md --- map-number-range.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 map-number-range.md diff --git a/map-number-range.md b/map-number-range.md new file mode 100644 index 000000000..adce7616d --- /dev/null +++ b/map-number-range.md @@ -0,0 +1,15 @@ +### mapNumRange + +Maps a number range to another number range. + +Returns a number mapped from the in range to the out range. + +```js +const mapNumRange = (num, in_min, in_max, out_min, out_max) => { + return (num - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; + } +``` + +```js +mapNumRange(5,0,10,0,100); // '50' +``` From 144d5145f6f7c2630f7adfc0a47d54c3a1b80b05 Mon Sep 17 00:00:00 2001 From: Yusof Bandar Date: Mon, 18 Feb 2019 14:24:55 +0000 Subject: [PATCH 02/11] Update map-number-range.md --- map-number-range.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/map-number-range.md b/map-number-range.md index adce7616d..b67f8c4da 100644 --- a/map-number-range.md +++ b/map-number-range.md @@ -1,8 +1,8 @@ ### mapNumRange -Maps a number range to another number range. +Maps a number from one range to another range. -Returns a number mapped from the in range to the out range. +Returns a mapped num from the in range to the out range. ```js const mapNumRange = (num, in_min, in_max, out_min, out_max) => { From cb9124e06b4a3ed5417c5554f05b7a6ee6da12f1 Mon Sep 17 00:00:00 2001 From: Yusof Bandar Date: Mon, 18 Feb 2019 14:26:10 +0000 Subject: [PATCH 03/11] Update map-number-range.md --- map-number-range.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map-number-range.md b/map-number-range.md index b67f8c4da..730f56c89 100644 --- a/map-number-range.md +++ b/map-number-range.md @@ -2,7 +2,7 @@ Maps a number from one range to another range. -Returns a mapped num from the in range to the out range. +Returns the mapped num from the in range to the out range. ```js const mapNumRange = (num, in_min, in_max, out_min, out_max) => { From a6a4ea777b3d30261788c6be110ab99bc6e77bcf Mon Sep 17 00:00:00 2001 From: Yusof Bandar Date: Mon, 18 Feb 2019 14:28:32 +0000 Subject: [PATCH 04/11] Rename map-number-range.md to mapNumRange.md --- map-number-range.md => mapNumRange.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename map-number-range.md => mapNumRange.md (100%) diff --git a/map-number-range.md b/mapNumRange.md similarity index 100% rename from map-number-range.md rename to mapNumRange.md From a944077d20a66815f1e306562ee1621473b3f4c8 Mon Sep 17 00:00:00 2001 From: Yusof Bandar Date: Fri, 22 Feb 2019 22:57:20 +0000 Subject: [PATCH 05/11] Update mapNumRange.md --- mapNumRange.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mapNumRange.md b/mapNumRange.md index 730f56c89..46e40b5cc 100644 --- a/mapNumRange.md +++ b/mapNumRange.md @@ -5,11 +5,9 @@ Maps a number from one range to another range. Returns the mapped num from the in range to the out range. ```js -const mapNumRange = (num, in_min, in_max, out_min, out_max) => { - return (num - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; - } +const mapNumRange = (num, in_min, in_max, out_min, out_max) => {return (num - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;} ``` ```js -mapNumRange(5,0,10,0,100); // '50' +mapNumRange(5,0,10,0,100); // 50 ``` From c3f7bc33fd8db0dc0f2248f24929d8cbe3149e20 Mon Sep 17 00:00:00 2001 From: Yusof Bandar Date: Fri, 22 Feb 2019 23:12:03 +0000 Subject: [PATCH 06/11] Update mapNumRange.md --- mapNumRange.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mapNumRange.md b/mapNumRange.md index 46e40b5cc..5b90907e0 100644 --- a/mapNumRange.md +++ b/mapNumRange.md @@ -2,10 +2,9 @@ Maps a number from one range to another range. -Returns the mapped num from the in range to the out range. - +Returns `num` mapped between `out_min` to `out_max` from `in_min` to `in_max` ```js -const mapNumRange = (num, in_min, in_max, out_min, out_max) => {return (num - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;} +const distance = (num, in_min, in_max, out_min, out_max) => (num - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; ``` ```js From 99b6bdb1063ce1f3f7385178eeef69db74c382eb Mon Sep 17 00:00:00 2001 From: Yusof Bandar Date: Fri, 22 Feb 2019 23:13:58 +0000 Subject: [PATCH 07/11] Update tag_database --- tag_database | 1 + 1 file changed, 1 insertion(+) diff --git a/tag_database b/tag_database index 0636ee018..785aa026e 100644 --- a/tag_database +++ b/tag_database @@ -179,6 +179,7 @@ longestItem:array,string,utility,intermediate lowercaseKeys:object,intermediate luhnCheck:math,utility,advanced mapKeys:object,function,intermediate +mapNumRange:math,beginner mapObject:array,object,advanced mapString:string,array,function,utility,beginner mapValues:object,function,intermediate From 7d7548ec548c398b81a2e96540ed90c0cd59ea3b Mon Sep 17 00:00:00 2001 From: Yusof Bandar Date: Fri, 22 Feb 2019 23:19:17 +0000 Subject: [PATCH 08/11] Update mapNumRange.md --- mapNumRange.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapNumRange.md b/mapNumRange.md index 5b90907e0..37661778a 100644 --- a/mapNumRange.md +++ b/mapNumRange.md @@ -2,7 +2,7 @@ Maps a number from one range to another range. -Returns `num` mapped between `out_min` to `out_max` from `in_min` to `in_max` +Returns `num` mapped between `out_min`-`out_max` from `in_min`-`in_max` ```js const distance = (num, in_min, in_max, out_min, out_max) => (num - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; ``` From f40812c38511913acfa88b3ecc26a7f82ca654c6 Mon Sep 17 00:00:00 2001 From: Yusof Bandar Date: Fri, 22 Feb 2019 23:20:35 +0000 Subject: [PATCH 09/11] Create mapNumRange.test.js --- mapNumRange.test.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 mapNumRange.test.js diff --git a/mapNumRange.test.js b/mapNumRange.test.js new file mode 100644 index 000000000..77ca11e8d --- /dev/null +++ b/mapNumRange.test.js @@ -0,0 +1,9 @@ +const expect = require('expect'); +const {mapNumRange} = require('./_30s.js'); + +test('mapNumRange is a Function', () => { + expect(mapNumRange).toBeInstanceOf(Function); +}); +test('Maps 5 to the range 0-100 from 0-10', () => { + expect(distance(5,0,10,0,100)).toEqual(50); +}); From 8a9436c16f2b2335cd1c6d5810d51281ac23ac0f Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Sat, 23 Feb 2019 11:25:11 +0200 Subject: [PATCH 10/11] Update mapNumRange.md --- mapNumRange.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mapNumRange.md b/mapNumRange.md index 37661778a..9b4285ded 100644 --- a/mapNumRange.md +++ b/mapNumRange.md @@ -2,7 +2,8 @@ Maps a number from one range to another range. -Returns `num` mapped between `out_min`-`out_max` from `in_min`-`in_max` +Returns `num` mapped between `out_min`-`out_max` from `in_min`-`in_max`. + ```js const distance = (num, in_min, in_max, out_min, out_max) => (num - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; ``` From dde8a39787b8b8e63ee29e1a0ce8308cbb2875f2 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Sat, 23 Feb 2019 11:26:23 +0200 Subject: [PATCH 11/11] Update mapNumRange.md --- mapNumRange.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mapNumRange.md b/mapNumRange.md index 9b4285ded..df12eb8ef 100644 --- a/mapNumRange.md +++ b/mapNumRange.md @@ -2,10 +2,10 @@ Maps a number from one range to another range. -Returns `num` mapped between `out_min`-`out_max` from `in_min`-`in_max`. +Returns `num` mapped between `outMin`-`outMax` from `inMin`-`inMax`. ```js -const distance = (num, in_min, in_max, out_min, out_max) => (num - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; +const distance = (num, inMin, inMax, outMin, outMax) => (num - inMin) * (outMax - outMin) / (inMax - inMin) + outMin; ``` ```js