first non repeating character javascript
function firstNotRepeatingCharacter(s) {
for (let i = 0; i < s.length; i++) {
if(s.indexOf(s.charAt(i)) == s.lastIndexOf(s.charAt(i))) {
return s.charAt(i)
}
}
return '_'
}
function firstRepeatingCharacter(str) {
for (let i = 0; i < str.length; i++) {
if (str.indexOf(str.charAt(i)) !== str.lastIndexOf(str.charAt(i))) {
return str.charAt(i)
}
}
return 'no results found'
}
Also in JavaScript:
- javascript if and statement
- discord.js
- route in component react
- jquery get return jquery object
- node express cors headers
- javascript picture delete after time
- add property with value in js
- based on scroll position and get data attribute javascript
- getstaticpaths with redux
- anonymous function js
- how to add json datasource in jasperserver
- how to move up in terminal
- store data in browser javascript
- javascript async script
- jquery table header agnostic of scroll
- find unique elements in array javascript
- javascript filter array by groups of highest
- get element by tag name
- get top items from json object
- what is package.lock.json
- function prototype javascript
- founder of javascript
- legend on click use default chartjs
- how to check if item is in list js