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

159
Views
How to get determine a variable from another variable

I have a trivia game in discord.js and need to be able to fetch questions and answers from a json file from a random number since i have multiple lists of questions that it would pick based off like 1.json, 2.json based of a random number gen but every time i try to fetch a question (trivia.QX) it says that trivia is not defined when the code calls for it if the number is 1 it goes for const trivia = require(./game/trivia/1.json) same with 2 and any others i have no clue why it wont work. (sorry about me forgetting to add .'s)

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

require takes a string input, meaning the file path needs to be in quotes.

const trivia = require('./game/trivia/1.json');
about 4 years ago · Santiago Gelvez 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!