Ensure question

PHOTO EMBED

Tue Oct 04 2022 09:47:44 GMT+0000 (Coordinated Universal Time)

Saved by @j_jivan #javascript

/*Given a string, write a function that returns the string with a question mark ("?") appends to the end, unless the original string ends with a question mark, in which case, returns the original string.*/

function ensureQuestion(s) {
  return s[s.length-1] === '?'? s : s + '?';
}
content_copyCOPY

https://www.codewars.com/kata/5866fc43395d9138a7000006/train/javascript