Skip to content

Commit 0ca1e6e

Browse files
authored
Update create-object-from-two-arrays.ts
1 parent 7d19442 commit 0ca1e6e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

TypeScript/create-object-from-two-arrays.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// Space: O(1)
33

44
function createObject(keysArr: any[], valuesArr: any[]): Record<string, any> {
5-
let obj: Record<string, any> = {};
5+
let result: Record<string, any> = {};
66
keysArr.forEach((key, index) => {
7-
if (obj[key] === undefined) {
8-
obj[key] = valuesArr[index];
7+
if (result[key] === undefined) {
8+
result[key] = valuesArr[index];
99
}
1010
});
11-
return obj;
11+
return result;
1212
};

0 commit comments

Comments
 (0)