Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript How do I track item lists for future IF statement

Noob2022

New Coder
Still working on the same issue posted https://codeforum.org/threads/better-than-a-long-list-of-if-statements.5571
However, the solution provided on that thread does not work (I think it's because) it's an old Rhino JS compiler (I was told).
So, nothing fancy on the suggestions. Thank you.

I have a list of about 30 items. I figured out a way to put it into array with a function and using FOR loop to get whether it's "Required" or "Not Required"

Code:
var itemReq =[fn(item1), fn(item2),...];
for (let i=0 in arr01)
{
  var itemReq = arr01[i];
  console.log(itemReq);
}

Next, if it's Required, I'll need to pass the item number into an IF statement to check whether it's "Submitted" or "Not Submitted".

Questions:
1) Do I need to create 2 array instead of the 1 array? 1st array will hold items on the list; and 2nd array to check if it's Required?
2) Should I change to IF statement to check on Submitted / Not Submitted? Or should I keep it in array?

I welcome suggestion(s) of a more efficient way of doing this.

Thank you.
 
How do you determine what of the 30+array are required? How is the item made "Submitted" or "Not Submitted"? Is the "Submitted" or "Not Submitted" determined from the 30+array or on the "Submitted" items?
 
How do you determine what of the 30+array are required? How is the item made "Submitted" or "Not Submitted"? Is the "Submitted" or "Not Submitted" determined from the 30+array or on the "Submitted" items?
Required or Not will be determined from the function that checks the database.
Submitted or Not will be determined from web forms but checks from staff members. Edit: So, held within variables in session?
 

Buy us a coffee!

Back
Top Bottom