1. Write a program to take a string and remove a character as desired by the user
constremoveCharacter=(inputString,removingCharacter)=>{constuniqueChar=[];letstrLength=inputString.length;console.log(strLength);for(leti=0;i<strLength;i++){if(inputString[i]!==removingCharacter){uniqueChar.push(inputString[i]);}}console.log(`After removing '${removingCharacter}', The final string is '${uniqueChar.join("")}'.`);};removeCharacter("development","e");
2. Write a program to take 10 numbers in an array and count the number of positive, negative numbers and zeros
constcountPositiveNegativeZero=(arr)=>{letpositive=0;letnegative=0;letzero=0;for(leti=0;i<arr.length;i++){if(arr[i]===0)zero++;elseif(arr[i]>0)positive++;elsenegative++;}console.log(`Positive Count: ${positive}, Negative Count: ${negative} and Zero Count: ${zero}`);};countPositiveNegativeZero([21,-25,7250,0,-982,0,472,-87,07,81284,-950,]);
3. Write a program to take a string and count the occurence of each character in the string.
constoccurrenceOfChar=(str)=>{str=str.toLowerCase();constcountEach={};conststrLength=str.length;letgetChar,count;for(leti=0;i<strLength;++i){getChar=str[i];count=countEach[getChar];countEach[getChar]=count ? count+1 : 1;}for(getCharincountEach){if(getChar!=" ")console.log(`Occurrence of ${getChar} is ${countEach[getChar]}`);}};occurrenceOfChar("A smooth sea never made a skillful sailor");