function move_first_word_to_end_of_string(s: string): string {
s = s.trim();
if (s.length === 0) return s;
let i: number = 0;
while (i < s.length && !/\s/.test(s[i])) {
i++;
}
const firstWord: string = s.slice(0, i);
const rest: string = s.slice(i).trim();
return rest.length === 0 ? firstWord : rest + " " + firstWord;
}
const s = "Would you like to know more? (Explore and learn)";
const result: string = move_first_word_to_end_of_string(s);
console.log(result);
/*
run:
"you like to know more? (Explore and learn) Would"
*/