- 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
- String
- Number
- Boolean
- Array
- Hash
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);
Write a function removeMinMax
that, given an array grades
, it will:
- Remove the highest and smallest score from the array
- Print out the
max
andmin
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);
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);
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]
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]]