Question: Explain this code: const takeAway = (string) => { const punc = [., ', !, :, ;, , ,, @]; // value of x

Explain this code:

const takeAway = (string) => {

const punc = [".", "'", "!", ":", ";", " ", ",", "@"];

// value of x is

for(i = 0; i< punc.length; i++){

string = string.replaceAll(punc[i], "")//creating empty array

}

return string;

}

const anagramChecker = (a,b) => {

firstParam = a.toLowerCase().split("").sort().join(""); // im a dot in place

secondParam = b.toLowerCase().split("").sort().join(""); // a decimal point

puncRmv1 = takeAway(firstParam);

puncRmv2 = takeAway(secondParam);

let result = puncRmv1 === puncRmv2

return result;

}

console.log(anagramChecker("a decimal point", "I'm a dot in place."));

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!