vendredi 12 juin 2020

How to move consonants to the end of the word in JavaScript

Could you please help me to understand how to move the consonant cluster to the end of the word.

let str = 'schwartz'
 let startwith = '^[aieouAIEOU].*'
 let matched = str.match(startwith)
 let store = []
    if(!matched){
    string = str[0]
    m = str.replace(str.charAt(0), '')
    store.push(m)
    console.log(store + string + 'way')
    }
     else{
     console.log(str +'ay')
      }

Aucun commentaire:

Enregistrer un commentaire