symbol/ how to split into two separate numbers



hi everyone so i’m solving the problem i have a script

this is the result from the web

1/5

how to split into two separate numbers?

the output is this how to do not let go if the number is greater than 5?

these are different numbers, for example:

1/4 
2/4

They need that the second numbers is not greater than 5

let maxPopulation = document.querySelector("#content_value > table:nth-child(2) > tbody > tr > td:nth-child(2) > table:nth-child(1) > tbody > tr:nth-child(2) > td:nth-child(5)").innerText

normal code would be done like this

but the sign prevents me from doing that

if ((maxPopulation)> = 5)

the problem, however, makes me a sign / I don’t know how to separate the two numbers and if the second one is bigger than 5 so that the script doesn’t continue to work

Answer

You can use split function:

result = '1/5';
let splitted = result.split('/');
if(splitted[1]>=5)
   DoSomething();

split returns an array, so second part is at position [1]

Update 1:

According to your comments you need specifically this:

const fieldValues = document.querySelector("#content_value > table:nth-child(2) > tbody > tr > td:nth-child(2) > table:nth-child(1) > tbody > tr:nth-child(2) > td:nth-child(5)").innerText

const splitted = fieldValues.split('/');

if(parseInt(splitted[1])>=5){
   // your code for equal or greater than 5
}
else{
   // your code for < 5
}


Source: stackoverflow