Home > OS >  Reading the javascript object
Reading the javascript object

Time:11-12

I'm trying to write a script for an auto bet (bustabit.com)

they have a manual about this on github

I want to read the "bust" object in the engine.history for writing an if statement

but I have no idea how javascript objects work ( i have not any experience in programming much )

I tried this but it's not working

if (engine.history(game.bust)=1.37){log("bust is 1.37")};

can someone help?

CodePudding user response:

The equal character is for assignment.

You should use == for equality checks read this

if (engine.history(game.bust)==1.37){log("bust is 1.37")};

Then

history(game.bust) means that history is a function which is taking a param which is is the value of the property bust inside the game object

Reading what are you sharing history has a method in it, which is going to cast the history to an array.

engine.history.toArray()

After that you can use array methods in order to find the history item you are looking for, for instance

const engineHistory = engine.history.toArray()
const element = engineHistory.find(historyItem => historyItem.bust == 1.37)
  • Related