Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/ * Given two arrays: studentNames and studentAges, complete the following 2 steps. The values and lengths of these arrays will be modified when graded

/*
Given two arrays: studentNames and studentAges, complete the following 2 steps.
The values and lengths of these arrays will be modified when graded so do
not hard code your output. You do not have to follow the steps exactly, what matters
is that your output matches for a variety of inputs (arrays).
The length will always be greater than or equal to 2, so do not worry about singular/plural.
There will not be students with the same age or name so do not worry about duplicates.
*/
var studentNames =['John', 'Jack', 'Jane', 'Julia', 'James'];
var studentAges =[22,25,21,32,24];
/*
EXPECTED OUTPUT USING PROVIDED ARRAYS:
There are 5 students.
The oldest student is Julia who is 32 years old.
*/
// STEP 1: In a sentence, log the number of students
// STEP 2: In a sentence, log the name and age of the oldest student
//2.1: Clone the age array (hint: slice)
//2.2: Sort the cloned age array, preserving the order of our original array.
//2.3: Get the highest age from the age array
//2.4: Using the highest age from the sorted array, Find what index it was in the original age array
//2.5: Using the index, log the name and age of the oldest student

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

More Books

Students also viewed these Databases questions