Q:

Using Javascript to extract part of a string

I am new to Javascript, and have been struggling to find a proper way to do what I'm looking for.
I have a heading "Page: Lastname Firstname"
What I want to do, is grab the last name ~only~ 
The last name will vary by length, and the page name will change as well but the format will always stay the same.

A:

Considering the format will remain like Name: fname lname. There is no middle name of something else. You can use split() by ' ' and get second element.

let str = "Page: Lastname Firstname"
console.log(str.split(' ')[1])

A:

const pageTitle = 'Page: Lastname Firstname'
const lastName = pageTitle.split(' ')[1]

Basically we are splitting pageTitle string into Array, using  as separator. And then we are accessing second [1] element of given Array.

