Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Backward Each Word solution in Uncategorized category for Backward Each Word by Elena_Korljukova
import assert from "assert";
function backwardStringByWord(text: string): string {
var q = text.match(/\b\w+\b/g);
if (q) {
for(let i of q)
text = text.replace(i,i.split('').reverse().join(''));
return text;
}
else return ''
}
console.log('Example:');
console.log(backwardStringByWord(''));
// These "asserts" are used for self-checking
assert.equal(backwardStringByWord(''), '');
assert.equal(backwardStringByWord('world'), 'dlrow');
assert.equal(backwardStringByWord('hello world'), 'olleh dlrow');
assert.equal(backwardStringByWord('hello world'), 'olleh dlrow');
assert.equal(backwardStringByWord('welcome to a game'), 'emoclew ot a emag');
console.log("Coding complete? Click 'Check' to earn cool rewards!");
June 15, 2020