Click here to Skip to main content
15,886,058 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
There is some mistake why this turns out
NF =[
  5, 5, 5, 5, 5,
  5, 5, 5, 5, 5
]
NC =[]
NT =[]


What I have tried:

JavaScript
var NF = []
var NC = []
var NT = []


for (var i = 0; i < ulSAlGlo.length; i++) {
  
    if (ulSAlGlo[0] == 0) {
        NC.push(ulSAlGlo[0]);
    }else if (ulSAlGlo[0] == 1) {
        NT.push(ulSAlGlo[0]);
      }else  (ulSAlGlo[0] > 1) 
        NF.push(ulSAlGlo[0]);
      
  }

  console.log(NF);
  console.log(NC);
  console.log(NT);
Posted
Updated 21-Feb-23 2:16am
v2
Comments
Richard Deeming 21-Feb-23 7:58am    
Firstly, this is an English-language site. Post your question in English.

Secondly, nobody can help you. You haven't explained what the problem is, and you haven't provided enough information for anyone to run your code to find out.

1 solution

We can't help: we have no idea what result you expect, no idea what input data you are feeding it, or any way to run your code under the sane conditions you do - and all of those are essential to debugging code.

So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. How you use it depends on your browser but a quick Google for the name of your browser and "javascript debugger" should give you the info you need.

Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
 
Share this answer
 
Comments
Richard Deeming 21-Feb-23 8:17am    
Looks like the OP has a post in the moderation queue for the JavaScript forum. Who wants to bet it's a verbatim repost of this question?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900