Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy I got 99 errors...

    ...but a glitch ain't one.

    Hey there, I am still learning so I apologize for the simple question. I'm just trying out a hypothetical logic statement that would still make sense using javascript.

    Example:

    if (problems == 99) {
    !=problem('a glitch');
    }
    Basically, I'd like it to mean "If I have 99 problems, a glitch isn't one of them." Any help is really appreciated!!

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,650
    Thanks
    80
    Thanked 4,636 Times in 4,598 Posts
    Maybe something like this?
    Code:
    var problemTypes = ["glitch","silly mistake","bad math","zamboni error","human failings"];
    
    if ( problems == 99 )
    {
        problemTypes.splice( 0, 1 ); // remove "glitch" from the list of problemTypes
    }
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    3,020
    Thanks
    56
    Thanked 566 Times in 563 Posts
    I think your request is a little vague, but this would be another interpretation...
    Code:
    <script type="text/javascript">
    
    var problemTypes = ["glitch","silly mistake","bad math","zamboni error","human failings"];
    
    var problems = problemTypes.length;
    
    if (problems==99){ //change to 5 for this block to run 
    if (problemTypes.indexOf("glitch")!=-1){
    alert("you have a glitch")
    } else {
    alert("a glitch is not one of your problems")
    }
    } else {
    alert("you do not have 99 problems")
    }
    </script>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •