i am trying to get a value from specific index of object property. i have used push function to push the value to object property. but when i call result.marks[0], it return all the values in array.
<html>
<body>
<p id="demo"></p>
<script>
try {
let result = {
marks: [], //
};
const n = 5;
let text = "";
for (let i = 0; i < n; i++) {
text += prompt("Enter value of " + i, i) + "<br>";
}
result.marks.push(text);
document.getElementById("demo").innerHTML = result.marks[0]; // it does not print the specific index value. it prints all the values
}
catch (err) {
document.write(err);
};
</script>
</body>
</html>