vendredi 29 janvier 2021

Multiple Conditions for an if statement in javascript [duplicate]

I'm pulling information off of a generic html table for a basketball algorithm I'm working on. I am saving all the stats I need inside the for loop into variables. The if statement I am trying to run should return players with a 'fppd' (fantasy point per dollar) that is greater than .045 AND if they are not injured. If they are injured, the table will display "GTD" or "O" so setting the condition inj = '' should return non-injured players.

Everything was working fine until I attempted to add multiple conditions to the if statement. Now I am somehow getting an "Uncaught TypeError: Cannot read property 'innerText' of undefined" I believe the problem is coming from the if statement. If you could take the time to help me out, it would be greatly appreciated

<script type="text/javascript">
const rows = document.querySelectorAll('tbody tr')
const statTable = document.querySelectorAll('tbody tr td')
const numOfPlayers = rows.length
for (let i=0; i<numOfPlayers; i++){
    let name = statTable[(i*8)+9].innerText
    let pos = statTable[(i*8)+8].innerText
    let opp = statTable[(i*8)+13].innerText
    let fPPG = statTable[(i*8)+10].innerText
    let sal = statTable[(i*8)+12].innerText
    let gamesPlayed = statTable[(i*8)+11].innerText
    let inj = statTable[(i*8)+14].innerText
    let fppd = fPPG/sal
    if ((fppd > .005) && (inj = ''))
    {
    console.log(name, pos, sal, opp, fPPG, gamesPlayed, fppd)
    }
}
</script>

 

Aucun commentaire:

Enregistrer un commentaire