Skip to content

Latest commit

 

History

History
executable file
·
115 lines (75 loc) · 1.98 KB

w02d4.md

File metadata and controls

executable file
·
115 lines (75 loc) · 1.98 KB

W2-D4 assessments

Data types

  • Explain the characteristics of each data type
  • What are the default falsey/truthy values?
  • Provide an example of it's use that showcases why/when may be useful to use them
  1. String
  2. Number
  3. Boolean
  4. Array
  5. Hash

Initialize Grades

Write a function initializeGrades that given a number num, will initialize an array with num random grades between 0 and 10.

var numStudents = 100;
var classGrades = [];

var initializeGrades = function (num) {

  //
  // Your Magic Here :)
  //

}

classGrades = initializeGrades(numStudents);
console.log(classGrades);

Remove Min/Max

Write a function removeMinMax that, given an array grades, it will:

  • Remove the highest and smallest score from the array
  • Print out the max and min in console.log
var numStudents = 100;
var classGrades = [];

var removeMinMax = function (grades) {

  //
  // Your Magic Here :)
  //

}

classGrades = initializeGrades(numStudents);
console.log(classGrades);

classGrades = removeMinMax(classGrades);
console.log(classGrades);

Remove Duplicates From Arrays

Write a function removeDuplicates that, given an array grades, it will remove the duplicate members from an array and return out the final array.

var classGrades = [];
classGrades = initializeGrades(100);

var removeDuplicates = function (grades) {

  //
  // Your Magic Here :)
  //

}

var uniqueGrades = removeDuplicates(classGrades);

Clone Array

Write a JavaScript function to clone an array.

Test Data :

var arrayClone = function (array) {

  //
  // Your Magic Here :)
  //

}

console.log(arrayClone([1, 2, 4, 0]));
=> [1, 2, 4, 0]

Deep Clone Array (OPTIONAL)

Write a JavaScript function that will clone an array. If any element of the array is an array, it will also make a copy of that array:

var deepClone = function (array) {

  //
  // Your Magic Here :)
  //

}

console.log(deepClone([1, 2, [4, 0]]));
=> [1, 2, [4, 0]]