JSFiddle - React, Tailwind, and code Playground
by jasonwilczak
HTML
<div id="output"></div>
JavaScript
PrintOutResults("Hello World");
//TODO update the "UserServiceFindUser" function to return developers that work at the specified company only
var developersAtAwesomeSauceInc = UserServiceFindUser(null,"developer","awesome sauce inc.");
PrintOutResults("Developers at Awesome Sauce Inc.",developersAtAwesomeSauceInc);
//TODO update the "UserServiceFindUser" function to return all people that work at the specified company
var peopleAtPandance = UserServiceFindUser(null,null,"pandance");
PrintOutResults("People at Pandance",peopleAtPandance);
//TODO update the "UserServiceFindUser" function to return all developers that work at the specified company and have the last name of Smith
var developersWithLastNameOfSmithWhoWorkAtAwesomeSauceInc = UserServiceFindUser("Smith","developer","awesome sauce inc.");
PrintOutResults("Developers With Last Name of Smith Who Work at Awesome Sauce Inc.",developersWithLastNameOfSmithWhoWorkAtAwesomeSauceInc);
function UserServiceFindUser(name,job,company) {
//TODO update logic for this function to user the params to return back the correct users
return UserServiceGetAllUsers();
}
function PrintOutResults(message,results) {
outputDiv = document.getElementById('output');
var outputText = 'Results: ' + message;
(results||[]).forEach( (item) => {
const itemId = item.id;
const itemName = item.name;
const itemJob = item.job;
const itemCompany = item.company;
outputText += `</br>ID: ${itemId}, Name: ${itemName}, Job: ${itemJob}, ${itemCompany}`;
});
outputDiv.innerHTML += outputText+'</br></br>';
}
function UserServiceGetAllUsers() {
return [
{id:1,name:"Bob Smith",job:"developer",company:"awesome sauce inc."},
{id:2,name:"Barb Tillo",job:"developer",company:"awesome sauce inc."},
{id:3,name:"May Axix",job:"product owner",company:"pandance"},
{id:4,name:"Jane Heartily",job:"developer",company:"awesome sauce inc."},
{id:5,name:"Jim...