Implementing functions [closed]

  • A checkSuspect function that takes a suspect object as parameter from the data structure below. Your function should return a number
    value indicating how many of their properties match the witness
    statement. You should use conditional statements to compare the
    suspect’s properties to the statement.

  • A findGuilty function which traverses the array of suspects and returns the object representing the guilty suspect, otherwise – return
    an empty object.

There are many possible ways of carrying out your duties, but you
should complete this task using ONLY the following commands:

  • function checkSuspect(suspectObj){}
  • function findGuilty(){}
  • if()
Witness statement:

  It was last Thursday, I heard noises outside so I looked out and saw a person in the steet.They seemed to be between the age of 18 and 42 years old.I remember they had a facial tattoo.They were wearing a black overcoat.They brobably weigh between 69 and 74 kg.I 'm not quite sure. They were fairly tall, I think between a height of 155 and 210 cm. It'
s so hard to remember right now.It was very dark and I could barely see, They were carrying a red backpack.I distinctly remember that they were wearing a dotted necktie, I remember thinking that was quite unusual.I 'll never forget their blue eyes. They wore thin metallic glasses. That'
s all I know officer.

  */

var lineupLog = [{
    "name": "ERMELINDA MOHWAWK",
    "glasses": "black",
    "coat": "white fur coat",
    "tattoo": "jellyfish",
    "accessory": "metal briefcase",
    "height": 186,
    "weight": 72,
    "age": 48
  },
  {
    "name": "LARRAINE GOODBURY",
    "glasses": "very thin",
    "coat": "red parka",
    "tattoo": "sword",
    "accessory": "orange plasic bag",
    "height": 181,
    "weight": 80,
    "age": 44
  },
  {
    "name": "MAJORIE WARMAN",
    "glasses": "thin metallic",
    "coat": "black overcoat",
    "tattoo": "facial",
    "accessory": "red backpack",
    "height": 162,
    "weight": 73,
    "age": 30
  },
  {
    "name": "LINETTE TINTLE",
    "glasses": "light tan",
    "coat": "yellow poncho",
    "tattoo": "big arrow",
    "accessory": "orange tote bag",
    "height": 162,
    "weight": 77,
    "age": 35
  },
  {
    "name": "JULIANA OORIN",
    "glasses": "dark brown",
    "coat": "green army coat",
    "tattoo": "anchor",
    "accessory": "laptop bag",
    "height": 170,
    "weight": 81,
    "age": 38
  },
  {
    "name": "JACQUELINE DORCEY",
    "glasses": "red",
    "coat": "green jacket",
    "tattoo": "dark black",
    "accessory": "big black envelope",
    "height": 179,
    "weight": 65,
    "age": 38
  },
  {
    "name": "GAYLA PORTOS",
    "glasses": "white",
    "coat": "blue overcoat",
    "tattoo": "neck",
    "accessory": "black duffle bag",
    "height": 177,
    "weight": 66,
    "age": 55
  }
];

var myFont;
var backgroundImg;

function preload() {
  myFont = loadFont('SpecialElite.ttf');
  backgroundImg = loadImage("Background.png");
}

function setup() {
  createCanvas(640, 480);
  textFont(myFont);
}

// Declare both your functions here





function draw() {
  //You don't need to alter this code
  image(backgroundImg, 0, 0);

  fill(255, 0, 0);
  text(findGuilty().name + " is guilty!", 60, 80);
}

:

  • A checkSuspect function that takes a suspect object as parameter from the data structure below.
    Your function should return a number value indicating how many of their properties match the witness statement.
    You should use conditional statements to compare the suspect’s properties to the statement.

  • A findGuilty function which traverses the array of suspects and returns the object representing the guilty suspect,
    otherwise – return an empty object.

There are many possible ways of carrying out your duties,
but you should complete this task using ONLY the following
commands:

  • function checkSuspect(suspectObj){}
  • function findGuilty(){}
  • if()