একটি জাভাস্ক্রিপ্ট ফাংশন লিখতে হবে যা একটি স্ট্রিং নেবে এবং প্রতিটি শব্দ থেকে শেষ স্বরবর্ণ অপসারণ করে একটি নতুন স্ট্রিং রিটার্ন করবে।
উদাহরণ − যদি স্ট্রিংটি হয় −
const str = 'This is an example string';
তবে আউটপুট হবে −
const output = 'Ths s n exampl strng';
উদাহরণ
নিচে কোডটি দেওয়া হল −
const str = 'This is an example string'; const removeLast = word => { const lastIndex = el => word.lastIndexOf(el); const ind = Math.max(lastIndex('a'), lastIndex('e'), lastIndex('i'), lastIndex('o'), lastIndex('u')); return word.substr(0, ind) + word.substr(ind+1, word.length); } const removeLastVowel = str => { const strArr = str.split(' '); return strArr.reduce((acc, val) => { return acc.concat(removeLast(val)); }, []).join(' '); }; console.log(removeLastVowel(str));আউটপুট
কনসোলে নিচের আউটপুট দেখা যাবে −
Ths s n exampl strng