Hi stackoverflow members, new in JS, trying to search some info through Internet, but unsuccesfully. So, I have a nested array of objects. I need to display some data based on my number. Lets say i have a number from 1-8. And if this number = arr1.Id, after I get in output arr1.Id + arr1.Address + P_min + P_max, then CombinedPointsIDs also comparing with all arr1.Id and outputed info with CombinedpointsIDs + Address + P_min + P_max. Unfortunately I cant explain better than before, so i posted an image with expected output. Thx for help.
let number = 1;
const arr1 = [
{
"Id": 1,
"Address": "noMatter1",
"P_min": 2.5,
"P_max": 6,
"CombinedPointsIDs": [2, 8, 4, 3]
},
{
"Id": 2,
"Address": "noMatter2",
"P_min": 6,
"P_max": 10,
"CombinedPointsIDs": [1, 5, 6, 3]
},
{
"Id": 3,
"Address": "noMatter3",
"P_min": 3.6,
"P_max": 6,
"CombinedPointsIDs": [4, 7, 5]
},
{
"Id": 4,
"Address": "noMatter4",
"P_min": 4.5,
"P_max": 6.5,
"CombinedPointsIDs": [3, 8, 6, 5]
},
{
"Id": 5,
"Address": "noMatter5",
"P_min": 2.5,
"P_max": 4.5,
"CombinedPointsIDs": [3, 4, 3, 2, 1]
},
{
"Id": 6,
"Address": "noMatter6",
"P_min": 4.5,
"P_max": 6.5,
"CombinedPointsIDs": [1, 5, 4, 7]
},
{
"Id": 7,
"Address": "noMatter7",
"P_min": 5,
"P_max": 7.5,
"CombinedPointsIDs": [1, 2, 8]
},
{
"Id": 8,
"Address": "noMatter8",
"P_min": 3,
"P_max": 5,
"CombinedPointsIDs": [2, 3, 5]
}
]
combinedPointsData+=
`
`
document.getElementById("combined-points").innerHTML = combinedPointsData;
A html code:
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<div class="container" id="container">
<div id="combined-points">
</div>
</div>
</body>
</html>
I tried to do some code in JS but I always get something i dont want to.
Im expecting to get something like that on webpage:
webpage example