0% found this document useful (0 votes)
9 views4 pages

Simple Problems Assignment

Uploaded by

dhorekaveri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

Simple Problems Assignment

Uploaded by

dhorekaveri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Write code to achieve outputs.

Problem 1:
let arr = [{
key: 1,
data: 5,
secondKey: 9
}];

let DataObject = {
1: {
infoKey: "some-info-for-key-1"
},
2: {
infoKey: "some-info-for-key-2"
},
3: {
infoKey: "some-info-for-key-3"
},
4: {
infoKey: "some-info-for-key-4"
},
5: {
infoKey: "some-info-for-key-5"
},
9: {
infoKey: "some-info-for-key-9"
}
};

Output:
=> arr = [{
key: {
infoKey: "some-info-for-key-1"
},
data: {
infoKey: "some-info-for-key-5"
},
secondKey: {
infoKey: "some-info-for-key-9"
}
}]
-------------------------------------------------------------------------------------------

Problem 2:
let arr = [{
key: 1,
data: 5
},{
key: 2,
data: 8
},{
key: 1,
data: 5
},{
key: 3,
data: 5
},{
key: 1,
data: 5
},{
key: 2,
data: 8
}];

output:
=>
let arr = [{
key: 1,
data: 5
},{
key: 2,
data: 8
},{
key: 3,
data: 5
}];

-------------------------------------------------------------------------------------------

Problem 3:

let obj1 = {
key1: 1,
key2: 2
};

let obj2 = {
key3: 3,
key4: 4
};

output:
obj1 = {
key1: 1,
key2: 2,
key3: 3,
key4: 4
};

-------------------------------------------------------------------------------------------

Problem 4:

let obj1 = {
key1: 1,
key2: 2
};

let obj2 = {
key3: 3,
key4: 4
};

output:
obj1 = {
key1: 10,
key2: 10,
key3: 10,
key4: 10
};

-------------------------------------------------------------------------------------------

Problem 5:

let obj1 = {
key1: 1,
key2: 2,
key3: 10
};

let obj2 = {
key3: 3,
key4: 4
};

output:
newObj = {
key1: 1,
key2: 2,
key3: 10,
key4: 4
};

You might also like