Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
how to filter array items in js without filter method?

here is the question

  • Filter out companies which have more than one 'o' without the filter method
  • 0: "Facebook" 1: "Google" 2: "Microsoft" 3: "Apple" 4: "IBM" 5: "Oracle" 6: "Amazon"
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You need to loop through the array and check if each word has more than one "o".

Here is a function to verify the word:

const verif=(word)=>{
  var s=0
  var l=word.length

  for(let i=0 ; i<=l;i++) {
    if (word[i]=="o") {
      s++
    }
  }
  if (s>=2) {
    return true
  } else {
    return false
  }
}
about 4 years ago · Juan Pablo Isaza Report

0

You can create a function a iterate through each array element

    function filterArray(arr, fn) {

    let filteredArray = [];
    for (let i = 0; i < arr.length; ++i) {
        if (fn(arr[i]) === true) {
            filteredArray.push(arr[i]);
        } 
    }
    return filteredArray;
}

function isIsogram (str) {
    return !/(.).*\1/.test(str);
}

const arr = ["Facebook", "Google", "Microsoft", "Apple", "IBM", "Oracle", "Amazon"];
console.log(filterArray(arr, isIsogram));
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!