Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

JavaScript I need help with my script, if your expert please take a look

SovietArctic

New Coder
I was making a infinite powers script for a game, powers is the items, and i just cant seem to get it to work. Can i have some help or idea's?
// ==UserScript==
// @name Test 2
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match Cellcraft.io
// ==/UserScript==

alert("Infinite Powers Script",
"Not Finished")
//powers
var powers = ["Recombine", "Speed", "Virus", "portal", "Freeze"]
Set.powers(Infinity);
powers.push[0].add(Recombine)
powers.push[1].add(Speed)
powers.push[2].add(Virus)
powers.push[3].add(portal)
powers.push[4].add(Freeze)

const Recombine = new Set(0);
const Speed = new Set(1);
const Virus = new Set(2);
const portal = new Set(3);
const Freeze = new Set(4);

Recombine.add(1000);
Speed.add(1000);
Virus.add(1000);
portal.add(1000);
Freeze.add(1000);

for (const item of Recombine) {
console.log(item);
// expected output: 1000
}

for (const item of Speed) {
console.log(item);
// expected output: 1000
}

for (const item of Virus) {
console.log(item);
// expected output: 1000
}

for (const item of portal) {
console.log(item);
// expected output: 1000
}

for (const item of Freeze) {
console.log(item);
// expected output: 1000
}
 
A friendly advice. For a start, there is atleast half-dozen missing semicolons. Before posting, i suggest you to use some validator to strip out the most obvious errors, such as these. If it does not work after that, we can start to figure out if there is error in logics etc.
 
The missing semicolons is sloppy indeed. Either use them or don't, but at least be consistent just for the sake of it. As Javascript does not require them they're probably not the problem here though. Please explain the exact problem - "i just cant seem to get it to work" does not help at all. How is this code used, is it being called at all, what exactly does not work ? Are you not seeing the output in the Console window ? Are there any errors in the Console log (I expect there might be some) ? Detail, details...
 
The missing semicolons is sloppy indeed. Either use them or don't, but at least be consistent just for the sake of it. As Javascript does not require them they're probably not the problem here though. Please explain the exact problem - "i just cant seem to get it to work" does not help at all. How is this code used, is it being called at all, what exactly does not work ? Are you not seeing the output in the Console window ? Are there any errors in the Console log (I expect there might be some) ? Detail, details...
Absolutely correct! Consistency in coding practices is critical, but the true challenge is identifying problems. Troubleshooting can be substantially aided by providing precise data such as how the code is utilized, probable error messages, or console logs. Precise data allows for a more effective and tailored approach.
 

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom