1const country = 'united kingdom'
2
3const countryArr = country.split(' ')
4const newcountry = countryArr
5 .map((val) => {
6 const pattern = new RegExp(`^[${val}]`, 'i')
7 return val.replace(pattern, `${val.charAt(0).toUpperCase()}`)
8 })
9 .join(' ')
10 .trim()
11
12console.log(newcountry)
13