Clear up the chaos behind these strings
Wed May 18 2022 11:13:56 GMT+0000 (Coordinated Universal Time)
Saved by
@ImrulKaisar
#javascript
// It seems like something happened to these strings
// Can you figure out how to clear up the chaos?
// Write a function that joins these strings together such that they form the following words:
// 'Javascript', 'Countryside', and 'Downtown'
// You might want to apply basic JS string methods such as replace(), split(), slice() etc
function myFunction (a, b) {
b = b.split('').reverse().join ('')
return a.concat(b).replace(/[^a-zA-Z ]/g, '')
}
myFunction('java', 'tpi%rcs') // returns 'javascript'
myFunction('c%ountry', 'edis') // returns 'countryside'
myFunction('down', 'nw%ot') // returns 'downtown'
content_copyCOPY
Comments