Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // checking for the same number of Os (letter as in Oh) and Xs in a string;
- function sameXOAmount1(str) {
- let numOfOs = 0;
- let numOfXs = 0;
- let arr = Array.from(str);
- arr.forEach(letter => {
- if (letter.toLowerCase() == 'o') {
- numOfOs++;
- }
- if (letter.toLowerCase() == 'x') {
- numOfXs++;
- }
- });
- return numOfOs == numOfXs;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement