const str = "hello world "; const a = str.slice(-1); if (a == " ") { console.log("ends with space"); }