I don't understand where is the mistake

Hello!
I am still new to javascript. I need to create a code for the equipment selection configurator (calculator) so that instead of a number (answer) it gives a link to the site.
Started simple, here is my code:

U=msg.payload.U;
I=msg.payload.I;
cosf=msg.payload.cosf;
kpd=msg.payload.kpd;

msg.payload.result = Math.round((Math.sqrt(3)*U*I*cosf*kpd)/1000);

if ('0.18'<=msg.payload.result and msg.payload.result<='2.2')
{
msg.payload.result='https://owen.ru1';
}
else 
{
    msg.payload.result='not';
}
else if ('0.37'<=msg.payload.result and msg.payload.result<='4')
{
   msg.payload.result='https://owen.ru2'; 
}
else if ('5.5'<=msg.payload.result and msg.payload.result<='22')
{
   msg.payload.result='https://owen.ru3'; 
}
return msg;

I got one porridge(

You would be better switching to monaco editor (search the forum for how to) as it is far better at highlighting your issues in JavaScript

Here is your code fixed up...

const U = msg.payload.U;
const I = msg.payload.I;
const cosf = msg.payload.cosf;
const kpd = msg.payload.kpd;

msg.payload.result = Math.round((Math.sqrt(3) * U * I * cosf * kpd) / 1000);

if (0.18 <= msg.payload.result && msg.payload.result <= 2.2) {
    msg.payload.result = 'https://owen.ru1';
} else if (0.37 <= msg.payload.result && msg.payload.result <= 4) {
    msg.payload.result = 'https://owen.ru2';
} else if (5.5 <= msg.payload.result && msg.payload.result <= 22) {
    msg.payload.result = 'https://owen.ru3';
} else {
    msg.payload.result = 'not';
}
return msg;
1 Like

Thank you very much, you helped out!