okay so I'm trying to shorten
var spells_function = {
"Empty": function () {
alert("Empty Spell")
},
"Shield": function () {
alert("Shield Spell")
},
"Charged Beam": function () {
alert("Charged Beam Spell")
},
"Movment": function () {
alert("Movment Spell")
},
"Invisible": function () {
alert("Invisible Spell")
},
"Telekinesis": function () {
alert("Telekinesis Spell")
},
"Tracker": function () {
alert("Tracker Spell")
}
}
to
for (var i = 0, spells =["Empty", "Shield", "Charged Beam", "Movment", "Invisible", "Telekinesis", "Tracker"]; i < 7; i++) {
Object.assign(spells_function, {spells[i]: function () {
alert(spells[i] + " spell")
}
});
}```
as far as i can understand it its not working because of line
`Object.assign(spells_function, {spells[i]: function () {`
and the `[i]` part of it I've tried `String(spells[i])`
now the issue here is i don't know to much about java script like i understand some basic stuff which I'm still learning(note: I'm not doing web development or anything like that I'm just testing it in google chrome console(haven't gotten to downloading it yet because i rarely use it)
as for the project I'm working on its a experiment for me to learn
i don't think there any more info to give
||i should of prob joined here(like talk around and what ever, i don't know) first and then asked a question instead of joining and asking a quest straight away lol||