Use more for-of

This commit is contained in:
John-David Dalton
2017-04-03 10:35:26 -07:00
parent f3957ac416
commit 3e2b0bb763
7 changed files with 18 additions and 33 deletions

View File

@@ -12,12 +12,11 @@
* // => { 'a': 1, 'b': 2 }
*/
function fromPairs(pairs) {
let index = -1
const length = pairs == null ? 0 : pairs.length
const result = {}
while (++index < length) {
const pair = pairs[index]
if (pairs == null) {
return result
}
for (const pair of pairs) {
result[pair[0]] = pair[1]
}
return result