const firstNonRepeatingCharacter = (str) => { for (let i = 0; i < str.length; i++) { let seenDuplicate = false; console.log("pass"); for (let j = 0; j < str.length; j++) { if (str[i] === str[j] && i !== j) { seenDuplicate = true; break; } } if (!seenDuplicate) { return str[i]; } } return null; // return null if no unique character is found };
- const firstNonRepeatingCharacter = (str) => {
- for (let i = 0; i < str.length; i++) {
- let seenDuplicate = false;
- console.log("pass");
- for (let j = 0; j < str.length; j++) {
- if (str[i] === str[j] && i !== j) {
- seenDuplicate = true;
- break;
- }
- }
- if (!seenDuplicate) {
- return str[i];
- }
- }
- return null; // return null if no unique character is found
- };