Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9244417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:01:29+00:00 2026-06-18T09:01:29+00:00

I have to decompose words into collections of letters in Javascript. Then I need

  • 0

I have to decompose words into collections of letters in Javascript. Then I need to be able to i) check whether a letter belongs to the collection and ii) to remove letters for this collection progressively.

For example, the word ‘cool’ would be decomposed into ‘c’, ‘o’, ‘o’, ‘l’. If I remove ‘o’, ‘a’ and ‘l’, I should be left with ‘c’, ‘o’ only.

What is the proper data structure to achieve this in Javascript?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:01:30+00:00Added an answer on June 18, 2026 at 9:01 am

    A string!

    var str = 'cool';
    

    To check if a character is in the string:

    if(str.indexOf('o') > -1) // the character is in the string
    

    To remove the first occurrence of a character:

    str = str.replace('o','');
    

    If you want to modify the string object to provide more “logical” representations of these actions you could do this:

    String.prototype.contains = function(char){
        return this.indexOf(char) > -1;
    };
    String.prototype.remove = function(char){
        return this.replace(char,'');
    };
    

    which you could use like this:

    if ('cheese'.contains('che'))
       alert('Velviva!');
    
    var str = 'hurt'.remove('r');   // 'hut'
        str = 'banana'.remove('n'); // 'baana'
        str = 'happy'.remove('c');  // 'happy'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a 4x4 matrix which I wish to decompose into 4 frequency bands
So, I have a situation where I need to pass in three values into
I have a massive function that I would like to decompose into multiple files.
I have been making an iPhone App where I need to identify and decompose
Have a painfully simple blog Post creator, and I'm trying to check if the
How can I decompose a tree into forest such that each tree contains even
Setup I have a graph library where I am trying to decompose things as
I've researched fast fourier transforms and have not been able to see a way
What is the shortest and most efficient way to decompose a string array into
I'm working in Matlab using Non-negative Matrix factorization to decompose a matrix into two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.