Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8322717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:28:47+00:00 2026-06-08T23:28:47+00:00

first time posting! I did some digging around and couldn’t find information on what

  • 0

first time posting!

I did some digging around and couldn’t find information on what I’m trying to achieve (sorry not the most advance javascript guy).

use case: prompt user a question, accept answer from user, weigh users’ answer to cases, return a result

problem: since javascript is case sensitive, im trying to learn how to accept both upper case and lower case in the prompt without using too many repetitive cases (ie. switch)

Below is a simple piece of code that I’m constructing to see if I can achieve the use case (obviously it’s not working though lol hence this question), thanks for the help in advance!

var jacketColor = function(x){
var x = prompt("color"?);
x===x.substring(0,1).toUpperCase||x===x.substring(0,1).toLowerCase)
};
}
var result;

switch (jacketColor) {

case "black":
    result = "pay $300";
break;

case "brown":
result = "Pay $200";  
break;

case "green":
result = "Pay $5";
break;

default:
result = "This color does not match my eyes!";
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T23:28:49+00:00Added an answer on June 8, 2026 at 11:28 pm

    You code should look something like that:

    function whatColor() {
      var x = prompt("color?");
      return x.toLowerCase();
    }
    
    var result;
    var jacketColor = whatColor();
    
    switch (jacketColor) {
      case "black":
        result = "pay $300";
        break;
      case "brown":
        result = "Pay $200";  
        break;
      case "green":
        result = "Pay $5";
        break;
      default:
        result = "This color does not match my eyes!";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

first time posting here, Googled for a few hours and I couldn't find anything.
First time posting, I will try to adhere to best practices. I'm trying to
first time posting here. I'm a beginner in jquery and i ran into some
This is my first time posting -- I found similar issues but not anything
First time posting here so take it easy with me, lol. I'm currently trying
First time posting here, so go easy on me. :) I am trying to
This is my first time posting a question on this site, but certainly not
First time posting. So I have to format some text in a element that
This is my first time posting on Stack Overflow, so hopefully I did everything
First time posting on this forum, and also very new to coding. Sorry if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.