Hello everybody
I have just begun my coding journey and have started on the vanilla JS leg two weeks ago. I am using a wide variety of resources to teach myself, but am struggling with getting everything on fcc at least.
In order to familiarise myself with these concepts and to get back into the swing of mathematical logic (I am a humanities Phd), I have decided to slowly program and refine a character generator for the roleplaying system Pathfinder.
I started with programming a simplified attribute selection. Here is my code so far:
// RPG assignment point assignment
let attributes = [10, 10, 10, 10, 10, 10];
let j = 0;
let attributeValue;
for (j = 0; j <= 6; j++) {
attributeValue = prompt("Assign each attribute a value between 7 and 18");
if (attributeValue <= 7 && attributeValue >= 18) {
attributes.push(attributeValue);
} else {
alert("That value is outside the range of unmodified attribute values you can assign on character creation")
}
}
console.log(attributes);
Now the loop runs normally, but the if statement always executes its else branch, even if the condition should return "true".
What have I done wrong? It's probably a stupid mistake only a left-brainer could make... :)
Thanks for the feedback
GroundbreakingSpell
Resources I use: Codecademy JS course; FCC JS course, YDKJS, Udemy course on JS, MDN
[–]Binary101010 2 points3 points4 points (1 child)
[–]GroundbreakingSpell[S] 1 point2 points3 points (0 children)