I'm trying to check if a string is present in othe...
# suitescript
n
I'm trying to check if a string is present in other string like a substring, I'm using below code for it but it is giving me error: TypeError: Cannot find function includes in object Re: test case ticket!!
b
dont expect to be able to use anything from es6 in suitescript 2.0
upgrade to suitescript 2.1 to do so, or polyfill
n
THanks for reply @battk which function I can use instead then!
b
look at the polyfill
n
well, I read it but I don't understand how to use it for my SUB and SUBJ variables who contains the string and substring
Copy code
if (!String.prototype.includes) {
  String.prototype.includes = function(search, start) {
    'use strict';

    if (search instanceof RegExp) {
      throw TypeError('first argument must not be a RegExp');
    }
    if (start === undefined) { start = 0; }
    return this.indexOf(search, start) !== -1;
  };
}
b
there is only really 1 line of interest in that code
all of the if statements are there to check for edge cases
n
I don't understand, which line! can you please pick it up for me!
b
nope, learning to read code is an essential skill
👍 1
n
haha, cool thanks a lot!
t
Suitescript 2.0 supports upto ES5.1. @battk I have never used 2.1, but I think I read it supports upto ES7. Is it so ?
b
SuiteScript Overview lists what version of ecmascript suitescript 2.1 supports
its higher than 7, which i believe is 2016
n
well the indexOf != -1 worked nicely here!