0

It is necessary in the operator to compare whether the text contains the value "100" in the answer should be god = 10

function myFunctiontest566() {
 var god = 16;
 var test = "test 100 pups"
 if(test == "*100") {var god = 10;}
}
  • 2
    You are looking for `if (test.includes("100")) {var god = 10;}` – A.A. May 14 '19 at 18:20
  • 1
    Also you'll not be updating the existing `god` variable if you redefine it within the if statement. – Adrian May 14 '19 at 18:23
  • 1
    you need to use `.includes()` to check if a value is a substring of a string. also you want to make sure to not create a new variable named `god` but update the existing one .... `function myFunctiontest566() { var god = 16; var test = "test 100" if(test.includes('100')) { god = 10;} console.log(god) }` – Hermes May 14 '19 at 18:24
  • The google apps script does not find the function: .includes() and .endsWith() – Михаил Таратенко May 15 '19 at 10:36

1 Answers1

0

You could take String#endsWith and the value 100 for a check.

function myFunctiontest566() {
    var god = 16,
        test = "test 100";

    if (test.endsWith("100")) {
        god = 10;
    } 
    console.log(god);
}

myFunctiontest566();
Nina Scholz
  • 376,160
  • 25
  • 347
  • 392