How to Convert Array to Uppercase in Node JS?
Hi friends,
In this example, I will show you how to convert an array to uppercase in node js. it's a simple example of convert an array to uppercase in node.js. This post will give you a simple example of node js array to uppercase. This tutorial will give you a simple example of the array to uppercase node.js. So, let's follow a few step to create an example of get array in uppercase node js.
This example is how to convert an array to uppercase in node js. I give you two examples of convert an array to uppercase in node js. I will use this example in the toUpperCase function and split function.
let's see below a simple example with output:
Install Node JS
This step is not required; however, if you have not created the node js app, then you may go ahead and execute the below command:
mkdir my-app
cd my-app
npm init
Example: 1
index.js
//create array list
myArray = ["banana","apple","orange","lemon"];
//create another variable (newArr) which would store your "loop through myArray"
newArr = myArray.map(arr => arr.toUpperCase())
console.log(newArr)
Output:
[ 'BANANA', 'APPLE', 'ORANGE', 'LEMON' ]
Example: 2
index.js
//create array list
myArray = ["piyush","pratik","mehul","keval","nikhil","kashyap","hardik","vimal","harshad"];
//convert to lowercase to UpperCase
strArray = String(myArray).toUpperCase().split(",");
console.log(strArray)
Output:
[
'PIYUSH', 'PRATIK',
'MEHUL', 'KEVAL',
'NIKHIL', 'KASHYAP',
'HARDIK', 'VIMAL',
'HARSHAD'
]
- How to Install Node Js and NPM Ubuntu?
- How to used Google ReCaptcha V3 in Node Js Express?
- How to Send Email with Attachment in Node js?
- How to Insert Data from Form into MySQL Database using Node js Express?
- Install Node Js and NPM Ubuntu 18.04/20.04/22.04 Tutorial
- How to Delete Data by id into MongoDB in Node JS?
- Install Node.js 16/17/18 on CentOS 8 Tutorial
- How to Upload File in MongoDB using Node js Express?