কম্পিউটার টিউটোরিয়াল

শেষ স্বরবর্ণ অপসারণ - JavaScript


একটি জাভাস্ক্রিপ্ট ফাংশন লিখতে হবে যা একটি স্ট্রিং নেবে এবং প্রতিটি শব্দ থেকে শেষ স্বরবর্ণ অপসারণ করে একটি নতুন স্ট্রিং রিটার্ন করবে।

উদাহরণ − যদি স্ট্রিংটি হয় −

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

  1. জাভাস্ক্রিপ্ট ট্রিতে নোড সরানো

  2. জাভাস্ক্রিপ্ট const কীওয়ার্ড

  3. জাভাস্ক্রিপ্টে Const এবং Let এর পার্থক্য

  4. জাভাস্ক্রিপ্টে বাক্যের সেকেন্ড লাস্ট শব্দের দৈর্ঘ্য বের করা