Zadanie Javascript

0

const inputStr = "abc123kot";
const expectedStr = "cba123tok"

function reverseLetters() {

}
const resultStr = reverseLetters(inputStr);

console.log(TEST PASS: ${resultStr === expectedStr});
jak zrobić , żeby funkcja odwróciła kolejność znaków tylko w słowach zawierające litery, a pomijające cyfry inputstr to jest nasze docelowe hasło expectedstr to jakie ma być.

0
const inputStr = "abc123kot";
let expectedStr;
function reverseLetters(myString){
const str = myString.match(/(\d+|[^\d]+)/g);

for (let i = 0; i<str.length;i++){
  if(!str[i].includes(str[i].match(/\d/))){
    str[i]=str[i].split('').reverse().join('');
  }
} 
expectedStr = str.join('');
return expectedStr;
}
0

Everything should be made as simple as possible but not simpler

function reverse(s){
    return s.split("").reverse().join("");
}

1 użytkowników online, w tym zalogowanych: 0, gości: 1