Copyright ©

Mongoose OS Forum

ATTENTION! This forum has moved to:

Do not post any new messages.

two string compare in mjs

let day = false;
if (a > "07" && a< "19") {
day = true; // 1

When a is "13", statement "1" is not reach.
But a === "13", its result is true.


  • mamuespmamuesp Germany/Northern coast

    If a is a string, you may try

    let hour = JSON.parse(a);
    let day = (hour > 7 && hour < 19);
    Thanked by 1yusp75
  • thanks.
    that is work follow your describe.
    mjs couldn't compare two string, maybe

  • mamuespmamuesp Germany/Northern coast

    MOS compares the contents of two strings for equality. A lexical evaluation with the ">" and "<" operators is not known to me. Therefore you first have to convert the strings into numbers and then compare them. Remember: MJS has the goal to be as slim as possible, therefore such rarely used functions are not implemented here.

Sign In or Register to comment.