Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript help with an assignment

HTML:
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="style.css">
 
  <title>Job Search</title>
</head>
<body>
  <h1>Job Search</h1>
  <div>
    <label for="job-title">Job Title:</label>
    <input type="text" id="job-title" placeholder="Enter job title">
  </div>
  <div>
    <label for="job-location">Location:</label>
    <input type="text" id="job-location" placeholder="Enter location">
  </div>
  <button id="search-button">Cerca</button>

  <h2>Results</h2>
  <ul id="results-list"></ul>
  <p id="countResult" ></p>

  <script src="scaricabile.js"></script>
</body>
</html>
CSS:
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap');


body{
    background-color: cyan;
}


#search-button{
   padding: 10px;
   color: beige;
   background-color: black;
}


#results-list{
    font-size: 20px;
    color: crimson;
}

#job-location{
    margin-bottom: 25px;
    
}

h1{
    text-align: center;
    margin-bottom: 25px;
}

h2{
    color: green;
}
Code:
/*
PART 1:
Today we will analyze a very common problem: creating search algorithms.
Your task is to create a function that will search by job location AND geographic location. These two values will be passed as parameters
We have provided you with an array called "jobs" at the bottom of the file, DO NOT modify it in any way.
The algorithm you need to create will search for BOTH job title and geographic location.
Take these three adverts for example:

 job1: location: "NY, US", title: "java dev"
 job2: location: "Genoa, IT" title: "web dev"
 job3: location: "US" title: "dev"

By simultaneously searching for job position "dev" and geographical position "US", you should only get job1 and job3 as results,
as job2 does not satisfy the condition placed on the geographical position.

REQUIREMENTS:
- your algorithm must return the results in the following form:
{
 result: [], <-- insert here the adverts that reflect the job position and the geographical position requested
 count: 0 <-- enter the total number of adverts found here
}

- your search must be "case insensitive" (it must not be affected by uppercase or lowercase letters in the searched words). This is possible by transforming everything to lowercase with .toLowerCase()


PART 2:
In the HTML page, insert 2 text inputs (one for the location and one for the job title, remember to diversify them with an id) and a button with the value "search"

When you click the button, the code must collect the values of the two inputs and feed them to the function you created in part 1.

After collecting and processing the data, it's time to show the results on the page:
 You can choose whether to use a simple ul/li or a table
 Go step by step and use lots of console.logs to eventually understand where you go wrong
 TIP: You'll need a for loop!

*/

// DO NOT MODIFY THIS ARRAY!
const jobs = [
  { title: "Marketing Intern", location: "US, NY, New York" },
  {
    title: "Customer Service - Cloud Video Production",
    location: "NZ, Auckland",
  },
  {
    title: "Commissioning Machinery Assistant (CMA)",
    location: "US, IA, Wever",
  },
  {
    title: "Account Executive - Washington DC",
    location: "US, DC, Washington",
  },
  { title: "Bill Review Manager", location: "US, FL, Fort Worth" },
  { title: "Accounting Clerk", location: "US, MD," },
  { title: "Head of Content (m/f)", location: "DE, BE, Berlin" },
  {
    title: "Lead Guest Service Specialist",
    location: "US, CA, San Francisco",
  },
  { title: "HP BSM SME", location: "US, FL, Pensacola" },
  {
    title: "Customer Service Associate - Part Time",
    location: "US, AZ, Phoenix",
  },
  {
    title: "ASP.net Developer Job opportunity at United States,New Jersey",
    location: "US, NJ, Jersey City",
  },
  {
    title: "Talent Sourcer (6 months fixed-term contract)",
    location: "GB, LND, London",
  },
  {
    title: "Applications Developer, Digital",
    location: "US, CT, Stamford",
  },
  { title: "Installers", location: "US, FL, Orlando" },
  { title: "Account Executive - Sydney", location: "AU, NSW, Sydney" },
  {
    title: "VP of Sales - Vault Dragon",
    location: "SG, 01, Singapore",
  },
  { title: "Hands-On QA Leader", location: "IL, Tel Aviv, Israel" },
  {
    title: "Southend-on-Sea Traineeships Under NAS 16-18 Year Olds Only",
    location: "GB, SOS, Southend-on-Sea",
  },
  { title: "Visual Designer", location: "US, NY, New York" },
  {
    title: "Process Controls Engineer - DCS PLC MS Office - PA",
    location: "US, PA, USA Northeast",
  },
  { title: "Marketing Assistant", location: "US, TX, Austin" },
  { title: "Front End Developer", location: "NZ, N, Auckland" },
  { title: "Engagement Manager", location: "AE," },
  {
    title: "Vice President, Sales and Sponsorship (Businessfriend.com)",
    location: "US, CA, Carlsbad",
  },
  { title: "Customer Service", location: "GB, LND, London" },
  { title: "H1B SPONSOR FOR L1/L2/OPT", location: "US, NY, New York" },
  { title: "Marketing Exec", location: "SG," },
  {
    title: "HAAD/DHA Licensed Doctors Opening in UAE",
    location: "AE, AZ, Abudhabi",
  },
  {
    title: "Talent Management Process Manager",
    location: "US, MO, St. Louis",
  },
  { title: "Customer Service Associate", location: "CA, ON, Toronto" },
  {
    title: "Customer Service Technical Specialist",
    location: "US, MA, Waltham",
  },
  { title: "Software Applications Specialist", location: "US, KS," },
  { title: "Craftsman Associate", location: "US, WA, Everett" },
  { title: "Completion Engineer", location: "US, CA, San Ramon" },
  { title: "I Want To Work At Karmarama", location: "GB, LND," },
  {
    title: "English Teacher Abroad",
    location: "US, NY, Saint Bonaventure",
  },
]







function work (name, posizion) {
 
  let reachJob = {
    results: [],
    count: 0,
  }


 
  for ( let i = 0; i<jobs.lenght;i++ ) {
const job2 = jobs[i];

let work1 = job2.title.toLowerCase();
let work2 = job2.location.toLowerCase();
let workTitol = titol1.toLowerCase();
let workLocation = posizion.toLowerCase();
let workSearch = name.includes(work2) && workTitol.toLowerCase(work1);

  }

 return reachJob
}
 



function NotResul (title1, location1) {
  let list = document.getElementById("results-list");
  let string = "";
  for (let i = 0;  i< NotResul.reachJob.lenght; i++){
    const job = NotResul.riultato[i];
    string += `<li> ${job.title} -${job.location} <li>   `
  }
}



document.getElementById('search-button').addEventListener('click', () => {
  const title = document.getElementById('job-title').value;
  const location = document.getElementById('job-location').value;

  const searchResult = work(title, location);
  NotResul(work);
});
 
Back
Top Bottom