www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] one condition with multiple possibilities?

Hybrid View

  1. #1
    Join Date
    Oct 2011
    Location
    Hamilton, Ontario
    Posts
    81

    resolved [RESOLVED] one condition with multiple possibilities?

    is there some kind of statement in javascript that illustrates the same logic as shown here?

    else if(result=='ad'){correct='option1' || correct='option2'}

    it's for a quiz i'm doing and want to user to be able to type in either option1 or option2 and still be correct in the case shown

  2. #2
    Join Date
    Mar 2009
    Posts
    485
    Use a "switch" statement.

    Code:
    var result;
    
    switch(answer)  //whatever the user input is, assumed to be a string here
    {
    case 'option1' :
     result="correct";
      break;
    case 'option2':
      result = "correct"
      break;
    case 'option3':
      result = "wrong";
      break;
    default:
      result = "you didn't answer";
    }

  3. #3
    Join Date
    Oct 2011
    Location
    Hamilton, Ontario
    Posts
    81
    oh, nice. thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles