String Is Lowercase

JavaScriptJavaScriptBeginner
Practice Now

This tutorial is from open-source community. Access the source code

Introduction

In this lab, we will explore the concept of checking if a given string is in lowercase or not using JavaScript. We will learn about the String.prototype.toLowerCase() method, which is used to convert a given string to lowercase. By the end of this lab, you will be able to write a function that checks if a string is in lowercase or not.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL javascript(("`JavaScript`")) -.-> javascript/BasicConceptsGroup(["`Basic Concepts`"]) javascript/BasicConceptsGroup -.-> javascript/variables("`Variables`") javascript/BasicConceptsGroup -.-> javascript/data_types("`Data Types`") javascript/BasicConceptsGroup -.-> javascript/arith_ops("`Arithmetic Operators`") javascript/BasicConceptsGroup -.-> javascript/comp_ops("`Comparison Operators`") subgraph Lab Skills javascript/variables -.-> lab-28425{{"`String Is Lowercase`"}} javascript/data_types -.-> lab-28425{{"`String Is Lowercase`"}} javascript/arith_ops -.-> lab-28425{{"`String Is Lowercase`"}} javascript/comp_ops -.-> lab-28425{{"`String Is Lowercase`"}} end

JavaScript Function to Check if a String is Lowercase

To check if a given string is lowercase, you can use the following JavaScript function. First, convert the string to lowercase using String.prototype.toLowerCase() and then compare it to the original string using strict equality (===).

const isLowerCase = (str) => str === str.toLowerCase();

Here's an example usage:

isLowerCase("abc"); // true
isLowerCase("a3@$"); // true
isLowerCase("Ab4"); // false

To use this function, open the Terminal/SSH and type node.

Summary

Congratulations! You have completed the String Is Lowercase lab. You can practice more labs in LabEx to improve your skills.

Other JavaScript Tutorials you may like