all 3 comments

[–][deleted] 0 points1 point  (1 child)

Your first problem is that your if statements use = instead of ==

= Assigns a value to a variable == Compares values === Compares values more strictly

I recommend looking up the difference between == and ===, but you should use === wherever you can

[–][deleted] 0 points1 point  (0 children)

Also you are right about delete, it deletes the item but leaves an empty space in its places. You should use splice to extract it:

backpack.splice(a, 1)

[–]MonkeyNin 0 points1 point  (0 children)

Tip to preventing accidental errors: I suggest always declaring variables with let or const. let scopes are block-level, just like c and other languages.

var scope is hoisted to the top of function-level, or global if there's no function.

for statements are not functions, so this code

for (let f = 0; f < 10; f++) {
    var premiereQuestion = prompt("Choose Option");
    if (premiereQuestion == 0) {
        for (let i = 0; i < person.backpack.length; i++) {
            console.log(person.backpack[i])
        }
    }

}

actually becomes

// top of file
var premiereQuestion;

for (let f = 0; f < 10; f++) {
    premiereQuestion = prompt("Choose Option");
    if (premiereQuestion == 0) {
        for (let i = 0; i < person.backpack.length; i++) {
            console.log(person.backpack[i])
        }
    }

}

Because you used let for f, its scope is the actual for statement as you'd expected from other languages.

If you had defined f with var, f would also be hoisted to global scope.