Use toUpperCase() or toLowerCase() to standardise your string before testing it.

Answer from Nemesis on Stack Overflow
🌐
Esdiscuss
esdiscuss.org › topic › case-insensitive-string-startswith-contains-endswith-replaceall-method
Case insensitive String startsWith, contains, endsWith, replaceAll method
February 18, 2013 - Le 17/02/2013 00:58, Biju a écrit : > In most time when user want to search something in a text, he/she > wants to do a case insensitive search. > For example to filter items displayed in list on a page. > Also on other applications, say any word processor, or in page search > in Firefox, IE, Chrome etc. > > So can we make the default behavior of new methods String.startsWith, > String.contains, String.endsWith case insensitive?
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › startsWith
String.prototype.startsWith() - JavaScript | MDN
This method lets you determine whether or not a string begins with another string. This method is case-sensitive. ... const str = "To be, or not to be, that is the question."; console.log(str.startsWith("To be")); // true console.log(str.startsWith("not to be")); // false console.log(str.s...
🌐
W3Schools
w3schools.com › jsref › jsref_startswith.asp
JavaScript String startsWith() Method
The startsWith() method is case sensitive. The endsWith() Method · string.startsWith(searchValue, start) JavaScript Strings · JavaScript String Methods · JavaScript String Search · startsWith() is an ECMAScript6 (ES6 2015) feature.
🌐
Medium
medium.com › dailyjs › string-startswith-method-in-javascript-b12ec998eb54
String startsWith() Method in JavaScript | by Samantha Ming | DailyJS | Medium
August 8, 2019 - const name = 'Samantha Ming';name.startsWith('S'); // true name.startsWith('M'); // false ... Frontend Developer sharing weekly JS, HTML, CSS code tidbits🔥 Discover them all on samanthaming.com 💛 ... JavaScript news and opinion.
🌐
Scaler
scaler.com › home › topics › javascript string startswith()
JavaScript String startsWith() Method - Scaler Topics
March 4, 2024 - The startsWith() method in javascript is case sensitive and is valid only for characters or strings.
🌐
Favtutor
favtutor.com › articles › javascript-string-startswith
JavaScript String startsWith() Method ( with Codes )
December 23, 2023 - We can declare a string in JavaScript by making a string literal using double quotes. The syntax for the same is given below: //declaring a string literal let a = "FavTutor" //printing the string console.log(a); ... The startsWith() is a built-in JavaScript method to determine or check whether a string starts with a specified set of characters.
Find elsewhere
🌐
DEV Community
dev.to › shshank › javascript-startswith-and-endswith-string-methods-a-brief-12nk
JavaScript startsWith() and endsWith() string methods, a brief - DEV Community
July 25, 2022 - Posted on Jul 25, 2022 · startsWith() and endsWith() in JavaScript are sibling methods that return a boolean true if a string starts or ends with a specific string, respectively. Else, false
🌐
Codecademy
codecademy.com › docs › javascript › strings › .startswith()
JavaScript | Strings | .startsWith() | Codecademy
August 8, 2023 - The substring is the specified characters that will be checked for in the string. It is case-sensitive. The position is optional. It is the index used to start searching for substring.
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-do-case-insensitive-string-comparison-of-strings-in-javascript
How to do case insensitive string comparison of strings in JavaScript
March 15, 2026 - There are four main methods to perform case-insensitive string comparisons: ... The toUpperCase() method converts all alphabetic characters in a string to uppercase. Numbers, special characters, and letters already in uppercase remain unchanged.
🌐
SheCodes
shecodes.io › athena › 37854-how-to-ignore-case-in-javascript
[JavaScript] - How to ignore case in JavaScript? - SheCodes | SheCodes
Learn how to perform case-insensitive comparisons in JavaScript using toLowerCase(), toUpperCase(), and regular expressions with the i flag.
🌐
Linux Tip
linuxscrew.com › home › programming › javascript › the startswith() method for javascript strings [examples]
The startsWith() Method for JavaScript Strings [Examples]
May 28, 2022 - let test = 'Use the Force, Luke.' test.startsWith('Use the); // true test.startsWith('the Force'); // false test.startsWith('the Force', 4); // true
Top answer
1 of 2
1

This smells like homework … … … And it stinks of the prof making you use startsWith() and endsWith() instead of checking for “topright” and “topleft” directly. Good prof!

OK – THINK about what you need to do:

  1. Accept user input

  2. Parse user input, ignoring case sensitivity

    1. Check for “help”
    2. Check for “stop”
    3. Check if it starts with “top”
      1. Check if it ends with “left”
      2. Check if it ends with “right”
    4. Check if the first 3 characters are “bot”
      1. Check if it ends with “left”
      2. Check if it ends with “right”
  3. User input may be mixed case, so we need to ignore case

Here’s the tools you have:

  • You know how to check equality with case insensitivity: orInput.equalsIgnoreCase(“stop”)

  • You know how to get the beginning and ending parts of String objects: orInput.startsWith() and orInput.endsWith()

  • You should know how to convert a String to all Upper or all Lowercase: orInput.toUpperCase() and orInput.toLowerCase();

  • You should understand that equalsIgnoreCase() compares two String objects and that startsWith() and endsWith() return Boolean values - so they can’t be used to compare against a String. You have to find a way to make that work if you MUST use these methods

  • And you should understand how Object methods are “additive” within context: You can take a String, apply a method that returns an Integer, apply a second method to the resulting Integer, etc. This allows you to do things like: String X = orInput.concat(rawInput).substring(2,orInput.length()) - so X is a String that is built by taking orInput, adding rawInput, starting at the 3rd character, and taking as many characters as the length of orInput. In your example, if the user typed “topright”, the value of X would be “prightto”. Useless to you as is, but it shows you how you can perform method on method
    You have everything here you need to make this work.

2 of 2
6

I’d want to provide the user some discretion in how they type instructions, such as top right, top-right, TOP RIGHT, upper left, and so on. To that aim, at the last if (, check whether cutInput begins with “top” or “up” AND check if cutInput concludes with “left” or “right,” all while being case-insensitive. Is this even possible?

public static void rightSel(Scanner scanner,char t)
{
  /*if (!stopping)*/System.out.print(": ");
    if (scanner.hasNextLine())
    {
     String orInput = scanner.nextLine;
        if (orInput.equalsIgnoreCase("help")
        {
            System.out.println("The following commands are available:");
            System.out.println("    'help'      : displays this menu");
            System.out.println("    'stop'      : stops the program");
            System.out.println("    'topleft'   : makes right triangle alligned left and to the top");
            System.out.println("    'topright'  : makes right triangle alligned right and to the top");
            System.out.println("    'botright'  : makes right triangle alligned right and to the bottom");
            System.out.println("    'botleft'   : makes right triangle alligned left and to the bottom");
        System.out.println("To continue, enter one of the above commands.");
     }//help menu
     else if (orInput.equalsIgnoreCase("stop")
     {
        System.out.println("Stopping the program...");
            stopping    = true;
     }//stop command
     else
     {
        String rawInput = orInput;
        String cutInput = rawInput.trim();
        if (

The final aim is for the user to be able to select one of four triangle orientations from a single line of input just like the example here . This was the best solution I could think of, although I’m still new to programming in general and may be overcomplicating things. If I am, and it turns out that there is a better approach, please let me know.

🌐
HCL Software
help.hcl-software.com › dom_designer › 9.0.1 › reference › r_wpdr_standard_string_startswithignorecase_r.html
startsWithIgnoreCase (JavaScript)
The following example compares the start of a string against a substring ignoring case. This comparison is true. var cities = new String("Paris Moscow Tokyo"); if (cities.startsWithIgnoreCase("paris")) return "Starts with Paris"; else return "Does not start with Paris"
🌐
Educative
educative.io › answers › how-to-use-the-startswith-method-in-javascript
How to use the startsWith() method in JavaScript
The startsWith() method in JavaScript is a String method that is used to check if a particular string starts with the exact string that is passed as an argument. The startsWith() method is case sensitive.
🌐
Vultr Docs
docs.vultr.com › javascript › standard library › string › startswith()
JavaScript String startsWith() - Check String Start
November 14, 2024 - Remember that startsWith() is case-sensitive: It's crucial to consider this when dealing with user inputs or data from various sources. Implement a basic case-insensitive check using toLowerCase() or toUpperCase().
🌐
Praat
praat.org › manual › _startsWith_caseInsensitive_.html
startsWith_caseInsensitive
startsWith_caseInsensitive ( string$, part$) determine whether · string$ starts with · part$. • · endsWith_caseInsensitive for determining whether · string$ ends in · part$. • · startsWith for case-sensitive matching. Functions · What was new in 6.4?
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-string-startswith-method
JavaScript String startsWith() Method - GeeksforGeeks
June 11, 2026 - // Checking if a URL starts with "https://" let url ='https://www.geeksforgeeks.org/'; console.log(url.startsWith('https://')); console.log(url.startsWith('http://')); //Checking if a filename starts with a specific extension let filename = 'script.js'; console.log(filename.startsWith('.js')); console.log(filename.startsWith('script.')); We have a complete list of Javascript String Methods, to check those please go through the Javascript String Complete Reference article.
🌐
Mastering JS
masteringjs.io › tutorials › fundamentals › compare-strings-ignore-case
Compare Two JavaScript Strings, Ignoring Case - Mastering JS
const strings = ['Alpha', 'Zeta', 'alpha', 'zeta']; strings.sort((str1, str2) => str1.localeCompare(str2, undefined, { sensitivity: 'accent' })); // Case insensitive sorting: ['Alpha', 'alpha', 'Zeta', 'zeta'] strings; You may be tempted to compare two strings using regular expressions and JavaScript regexp's i flag.