Skip to content

Instantly share code, notes, and snippets.

@sandrabosk
Created November 5, 2019 22:01
Show Gist options
  • Save sandrabosk/ac2daab8b60fdb0e7afd6b40b7d0d03f to your computer and use it in GitHub Desktop.
Save sandrabosk/ac2daab8b60fdb0e7afd6b40b7d0d03f to your computer and use it in GitHub Desktop.
const capsMs = cities1.filter(theCity => theCity[0] === "m")
                      .map(city => {
                        if (city.includes(" ")){
                          let splitted = city.split(" ");
                          const len = splitted.length;
                          for (let i = 0; i < len; i++){
                            splitted[i] = splitted[i][0].toUpperCase() + splitted[i].slice(1);
                          }
                          return splitted.join(" ");
                        }
                        return city[0].toUpperCase() + city.slice(1)
                      })

console.log(capsMs);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment