Javascript Code for user's target.

Hey all, so, I'm not very fluent in Javascript and have no idea how to accomplish but, I was looking to see if somebody could help me change the following a bit. The bolded part will randomly select living enemy targets and randomly hit them. I was wanting to change it so that it only hits the target the user selects.

Spoiler: Target Core Notetag
<Custom Target Eval>
var missiles = Math.floor((Math.random()*100)+1)
var hits = 0
if (missiles >= 1 && missiles < 15) {
//4 missiles
hits = 4
}else if (missiles >= 16 && missiles < 30){
//5 missiles
hits = 5
}else if (missiles >= 31 && missiles < 51){
//6 missiles
hits = 6
}else if (missiles >= 52 && missiles < 71){
//7 missiles
hits = 7
}else if (missiles >= 72 && missiles < 88){
//8 missiles
hits = 8
}else if (missiles >= 89 && missiles < 101){
//9 missiles
hits = 9
}
for (var i = 0; i < hits; ++i) {
var member = foes.aliveMembers()[Math.floor(((Math.random()*foes.aliveMembers().length)))];
if (member) targets.push(member);

}
</Custom Target Eval>

Any help would be appreciated!
I think (I THINK) that most of the damage calculations are done on the reciever side.
so, the target of any used item is "self".
through "self", you then get "friends of *self*" and "opponents of *self*"
The target core documentation says that if the skill is single target, 'target' references the target chosen by player when picking the skill.

I'm not at a PC right now, but that should mean that if you change the for loop so that it's pushing target to the targets array, it should target the original target multiple times (up to hits number), possibly like below (although I'm not 100% sure right now)
Code:
for (var i = 0; i < hits; ++i) {
if (target) targets.push(target);
@ramza worked like a charm, you da' best! Thank you! 😀

Original thread: https://forums.rpgmakerweb.com/threads/javascript-code-for-users-target.76930/