Skip to content

Files

Latest commit

 

History

History
24 lines (14 loc) · 429 Bytes

Last and Second Last.md

File metadata and controls

24 lines (14 loc) · 429 Bytes

Given a string, create a new string made up of its last two letters, revered and seperated by a space.

Example, given a word 'bat', return 't a'

let testLetters = 'bat'

function lastLetters(word) {
    let lastTwo= word.slice(-2).split("").reverse().join(" ");

}

console.log(lastLetters(testLetters));

[Tiktok]

let word = 'bat';

console.log(word.split('').reverse().join(' ').slice(0, 3))