-4

So I made this code awhile ago, and it worked then, but now it won't. Can someone tell me what's wrong? What the code does is simple: I take a weapon damage value from a Fallout game (averaging the value first if FO1/FO2/FOT), tell it what game it's from, and it outputs how much damage it does in d20 Modern. I don't know if explaining what it does helps, but I hope it's clear.

var systemSelect = prompt("What system are you using? FO, F2, FT, F3, or FNV?")
var damage = parseInt(prompt("How much damage does the weapon do?"))

if (systemSelect === "FO" or "F2" or "FT") {
    if (damage >= 1 && < 11) {
        damage = "2d4";
    } else if (damage >= 11 && < 26) {
        damage = "2d6";
    } else if (damage >= 26 && < 46) {
        damage = "2d8";
    } else if (damage >= 46 && < 61) {
        damage = "2d10";
    } else if (damage >= 61 && < 81) {
        damage = "2d12";
    } else if (damage >= 81 && < 101) {
        damage = "4d6";
    } else {
        damage = "2d20";
    }
}

if (systemSelect === "F3" or "FNV") {
    if (damage >= 1 && < 8) {
        damage = "2d4";
    } else if (damage >= 8 && < 15) {
        damage = "2d6";
    } else if (damage >= 15 && < 25) {
        damage = "2d8";
    } else if (damage >= 25 && < 37) {
        damage = "2d10";
    } else if (damage >= 37 && < 61) {
        damage = "2d12";
    } else if (damage >= 61 && < 81) {
        damage = "4d6";
    } else {
        damage = "2d20";
    }
}
Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
  • 3
    Please include the relevant code here instead of linking to an external site. If the external site changes or goes away, this question then loses context and becomes useless. – Andrew Marshall Sep 20 '14 at 16:21
  • 1
    You need to include the relevant parts of your code in the question and make some effort to identify exactly which bit of it isn't working any more. – Tom Fenech Sep 20 '14 at 16:21
  • You should edit the "javascript" tag on this question, because this seems to be some other language. –  Sep 20 '14 at 16:28

1 Answers1

0

Your problem seems to be bad syntax in your if-conditions.

First of all, you can't say if (damage >= 1 && < 11), you need to specify the variable in each condition, i.e. if (damage >= 1 && damage < 11).

Secondly, the "or" operator is not or, it's || so you need if (systemSelect=="FO" || systemSelect=="F2" || systemSelect=="FT")

Fix those problems and try again - good luck :)

Constantinos
  • 1,138
  • 9
  • 18