1

.content and noiseWords are the arrays which consist of strings. My aim is to remove noiseWords from content. Both content and noiseWords are not global variables. Can I access noiseWords in the word()? Is line 4 correct? If not, then how can I access noiseWord inside word()?

word(content){
// this function remove noiseWords from the Content 
//and then return the content

noiseWords.split(/\s+/).map((w) => 
normalize(w));//line4    

 }

addNoiseWords(noiseWords){
//this function consists noisewords
}
1
  • 2
    Welcome to stackoverflow! Please take a look at How to Ask a Good Question. In this case, providing the entire code fragment you are trying, with an example of the input data and your desired output would help people provide you with a better answer. Commented Sep 16, 2018 at 1:56

1 Answer 1

1

Can I access noiseWords in the word()?

No

Is the line 4 correct? If not then how can I access noiseWord inside word()? I have mentioned "line 4" in the code.

You need to pass that array as parameter in function word(), for example:

function word(content, noiseWords){...}

or pass an object with those values:

function word(obj){
    var {content, noiseWords} = obj;
    .
    .
    .
}

or pass an array with those values:

function word(array){
    var [content, noiseWords] = array;
    .
    .
    .
}
Sign up to request clarification or add additional context in comments.

2 Comments

I am not supposed to do so. I can't use word(content,noiseWords). DO you have any other idea?
function word(obj){ var {content, noiseWords} = obj; . . } // How can I access noiseWords inside word since noiseWord is not a global varibale? Also I cant change the parameters of word. It has to be word(content).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.