You should be using the code tags (the </> icon on the top bar). It will preserve indents and not turn your brackets into BBCode commands. (see how
[i] turned half your post into italics?)
Code:
for (let i = 0; i < thearray.length; i++) {
if(thearray[i] == RndmData)
So far, so good...
Code:
eval("specialObj.item") + i.ToString() = "Big boop!"
What on earth is any of that supposed to be doing?
1 - Why are you using the string "specialObj.item" instead of referring to your variable? This seems to be a continuing point of confusion for you and it's just...kinda weird
😛 If you put something in quotes, that's a string, the actual sequence of characters. If you don't, it's referring to a code object (variable, function, etc.). That's it.
2 - Presuming you meant to reference the strings you stored in your little hash array earlier, why are you running an eval on it?
3 - There's no reason to call toString (which you misspelled) on i. If you add a number (which i is) onto the end of a string, it will concatenate the string.
4 - Both eval and toString are going to return constant values. You can't assign constant values to something else. That's like saying "4 + 7 = 19" - it's an invalid left hand assignment.
yeah so something like that instead of having an if statement a million times. in honesty I only have to do it 40 time but that's still a lot and I'm not sure how it'll affect performance.
Why would if statements affect performance? As far as your computer knows, there's no difference between running a loop with 40 iterations and going down 40 lines of if statements, it's performing the exact same operations to evaluate the condition.
The only difference is for your fingers.