সমস্যা
আমাদের একটি জাভাস্ক্রিপ্ট ফাংশন লিখতে হবে যা একটি স্ট্রিং নেবে এবং একটি স্পেস-ফ্রি স্ট্রিং ফেরত দেবে (যে স্ট্রিংয়ে সকল স্পেস খালি স্ট্রিং দিয়ে রিপ্লেস করা হয়েছে)।
উদাহরণ
নিচে কোডটি দেওয়া হলো:
const str = 'some random string ex a m pl e';
const removeSpaces = (str = '') => {
let res = '';
for(let i = 0; i < str.length; i++){
const el = str[i];
if(el !== ' '){
res += el;
continue;
}
}
return res;
};
console.log(removeSpaces(str));আউটপুট
somerandomstringexample