Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Deleting the duplicate strings based on the ending characters - JavaScript
We are required to write a JavaScript function that takes in an array of strings and deletes each one of the two strings that ends with the same character −
For example, If the actual array is −
const arr = ['Radar', 'Cat' , 'Dog', 'Car', 'Hat'];
Then we have to delete one and keep only one string ending with the same character in the array of distinct letters.
Example
Following is the code −
const arr = ['Radar', 'Cat' , 'Dog', 'Car', 'Hat'];
const delelteSameLetterWord = arr => {
const map = new Map();
for(let i = 0; i Output
This will produce the following output in console −
[ 'Radar', 'Cat', 'Dog' ]
Advertisements
