Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
How to JS Strings and Vars for complete begginer

Im learning JS programming but Im completely new and not familliar with terms and usage yet. Im coding macros and I want to substitute STRVALUE for var V1.

Can someone hint how to use variables in getString?

Its meant to run SCRIPT1 upon detecting XXX in chat, but Im adding alot of possible scripts. I would love to combine two or more variables instead of STRVAL. something like STRVAL== "V1 + V2 or V3"

var V1 = XXX
var V2 = Y
var V3 = Z

if (event.text.getString() == "STRVAL")
JsMacros.runScript("SCRIPT1.js")

Im running different Scripts depending on String output and I have to include STRVAL for each if statement, after every runScript like

if (event.text.getString() == "STRVAL1")
JsMacros.runScript("SCRIPT1.js")

if (event.text.getString() == "STRVAL2")
JsMacros.runScript("SCRIPT2.js")

if (event.text.getString() == "STRVAL3")
JsMacros.runScript("SCRIPT3.js")

I would like to use shortcut ID's of Variables just including on top.

var V1 = XXX
var V2 = Y
var V3 = Z

Thanks for help, as I said Im really green with JS yet.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

First of all string variables are diclared with cotes ("" or '') so when declaring the V1,V2 and V3 you should write :

var V1 = 'XXX'
var V2 = 'Y'
var V3 = 'Z'

now for if statement i belive you need to know how includes() works it returns a boolean variable that determines if a string contains another string

eg:

"Hello word".includes("word")
 > true

so it's perfect for you case like so :

var V1 = 'XXX'
var V2 = 'Y'
var V3 = 'Z'
if (event.text.getString().includes(V1 + V2))
    JsMacros.runScript("SCRIPT1.js")

or with arrays (it's pretty much the same)

if ([V1 + V2 , V3].includes(event.text.getString()))
    JsMacros.runScript("SCRIPT1.js")

Good luck learning Js

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!