0

I have this:

if (rows[i]["SUB_STATUS"] == "ACTIVE") {
   console.log("status is " + rows[i]["SUB_STATUS"])
 } else if (rows[i]["SUB_STATUS"] == "INACTIVE") {
    console.log("status is inactive " + rows[i]["SUB_STATUS"])
}

and I want to count the number of rows that my table holds with rows[i]["SUB_STATUS"] = to inactive, and active. How is this possible?

1 Answer 1

1

Without having more context, I can't tell exactly how you want this information stored. However, it is rather simple to keep a count of occurrences. You can store the number of times you encounter either of these situations in variables.

let numActive = 0;
let numInactive = 0;

if (rows[i]["SUB_STATUS"] == "ACTIVE") {
   numActive++;
   console.log("status is " + rows[i]["SUB_STATUS"])
 } else if (rows[i]["SUB_STATUS"] == "INACTIVE") {
    numInactive++;
    console.log("status is inactive " + rows[i]["SUB_STATUS"])
}

// Do something with these values
console.log('Number of active:', numActive);
console.log('Number of inactive:', numInactive)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.