Created
October 17, 2019 11:37
-
-
Save gthrm/68b5de393e33dad7c6a19b79c7340f23 to your computer and use it in GitHub Desktop.
Создает массив из одинаковых объектов с уникальным id по указанной длине
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const createContactsArray = (keys, values, len) => { | |
let i, arr = [] | |
for (i = 1; i <= len; i++) { | |
let obj = {} | |
for (let index = 0; index < keys.length; index++) { | |
obj[keys[index]] = keys[index] === 'id' ? `00${i + index}` : values[index] | |
} | |
arr.push(obj); | |
} | |
return arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment