Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

142
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda