Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

friends!!!!! lets show our friends how much we like them - create an ar…

Question

friends!!!!!
lets show our friends how much we like them

  • create an array called friends that contains at least 5 string elements
  • use a for loop to iterate over the array and add \!!!\ to the end of each of your friends names

hack the schools database!
weve broken into the mainframe! weve found where our grades are stored, lets give ourselves a little boost.
https://jsbin.com/duwuluwuki/3/edit?js,console

  • create a for - in loop to iterate over the keys of the grades object
  • inside the for - in loop change each value of the object to 100
  • hint: you will need to use bracket notation

Explanation:

Step1: Create friends array

const friends = ["Rachel", "Monica", "Phoebe", "Joey", "Chandler"];

Step2: Loop to add "!!!"

for (let i = 0; i < friends.length; i++) {
  friends[i] = friends[i] + "!!!";
}

Step3: Define grades object (sample)

const grades = {
  math: 85,
  english: 90,
  science: 78,
  history: 82,
  art: 95
};

Step4: For-in loop to set grades to 100

for (const subject in grades) {
  grades[subject] = 100;
}

Answer:

Code for Friends Task:
// Create friends array with 5+ names
const friends = ["Rachel", "Monica", "Phoebe", "Joey", "Chandler"];

// Iterate and add "!!!" to each name
for (let i = 0; i < friends.length; i++) {
  friends[i] += "!!!";
}

// Verify result
console.log(friends);
Code for Grades Task:
// Sample grades object (matches typical stored structure)
const grades = {
  math: 85,
  english: 90,
  science: 78,
  history: 82,
  art: 95
};

// Iterate over object keys and set values to 100
for (const subject in grades) {
  grades[subject] = 100;
}

// Verify result
console.log(grades);

When run, the friends array will output ["Rachel!!!", "Monica!!!", "Phoebe!!!", "Joey!!!", "Chandler!!!"] and the grades object will show all values set to 100.