As a newcomer to JavaScript, I am attempting to create a loop for a fight between two fighters. I have set up an array containing the details of the fighters and linked a button in my HTML to trigger the JavaScript code. The objective is to execute a loop where each fighter's attack damage is deducted from the other fighter's health points, with the outcome of the fight displayed on the HTML page afterwards. However, I am unsure about how to proceed or if I have set it up correctly. Any guidance would be greatly appreciated. Below is what I have implemented so far:
var fighters = [
{
"name":"Abdi",
"HP": 100,
"DMG": 20,
}
{
"name": "chriz",
"HP": 100,
"DMG": 11,
}
]
function myFunction() {
for (var i = 0; i < fighters.length; i++) {
fighters[i]
}
}