Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

148
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda