JavaScript Hapus ruang dari dua sisi string
const string = " this contains spaces ";
string.replace(/\s{2,}/g, '').trim()
Borma
const string = " this contains spaces ";
string.replace(/\s{2,}/g, '').trim()