'What does my instructor mean by declare each of the variables marked with "**" in the appropriate scope and using the appropriate type

I'm really lost and just don't understand what I'm supposed to be doing here. The way my brain works I need some examples. I don't want the answers. everything I've read just isn't clicking.

The whole //declare each of the variables marked with "**" in the appropriate scope and using the appropriate type. Just doesn't work out in my head and I cant find any examples of this. Usually pretty good at finding what I need here.

// declare each of the variables marked with "**" in the appropriate scope and using the appropriate type

// create an event listener that calls the curveGrade() function when the Curve It!! button is clicked

// create an event listener that resets the scores and grades to their defaults when the Reset button is clicked

function applyBell(grade, index, ary) {
    switch (true) {
        case grade >= (mean + (gradeSlice * 2)): 
            ary[index] = 'A'
            break
        case grade >= (mean + gradeSlice):  
            ary[index] = 'B'
            break
        case grade >= (mean):
            ary[index] = 'C'
            break
        case grade >= (mean - gradeSlice): 
            ary[index] = 'D'
            break
        default:
            ary[index] = 'F'
            break
    }
}

function convertArray(obj) {
    ary = obj.value.split(',')
    ary = ary.map(function (x) {
        return parseInt(x)
    })
    return ary
}

// Condense the number of lines within the curveGrade() function as much as possible by converting 
// the functions to arrow functions. You can also condense the number of lines by combining some 
// separate lines of code into single lines. It currently has 18 lines of code. Without counting  
// empty lines, can you get the number of lines down to 8?

function curveGrades() {
    **sum = function (accumulator, currentValue) {
        return accumulator + currentValue
    }

    **sumGrades = function(array) {
        return array.reduce(sum)
    }

    **aryGrades = convertArray(document.querySelector('#scores'))

    **minGrade = aryGrades.reduce(function(a, b) {
        return Math.min(a, b)
    })
    
    **maxGrade = aryGrades.reduce(function(a, b) {
        return Math.max(a, b)
    })
    
    **mean = sumGrades(aryGrades) / aryGrades.length

    **range = maxGrade - minGrade

    gradeSlice = range / 5

    aryGrades.forEach(applyBell)

    // write the value of aryGrades to the grades div in the HTML document
}

Lost student in search of help!

// declare each of the variables marked with "**" in the appropriate scope and using the appropriate type

// create an event listener that calls the curveGrade() function when the Curve It!! button is clicked

// create an event listener that resets the scores and grades to their defaults when the Reset button is clicked

curveIt = document.getElementById("submit")
curveIt.addEventListener("click", curveGrades)
output = document.getElementById("grades")

function applyBell(grade, index, ary) {
    switch (true) {
        case grade >= (mean + (gradeSlice * 2)): 
            ary[index] = 'A'
            break
        case grade >= (mean + gradeSlice):  
            ary[index] = 'B'
            break
        case grade >= (mean):
            ary[index] = 'C'
            break
        case grade >= (mean - gradeSlice): 
            ary[index] = 'D'
            break
        default:
            ary[index] = 'F'
            break
    }
}

function convertArray(obj) {
    ary = obj.value.split(',')
    ary = ary.map(function (x) {
        return parseInt(x)
    })
    return ary
}

// Condense the number of lines within the curveGrade() function as much as possible by converting 
// the functions to arrow functions. You can also condense the number of lines by combining some 
// separate lines of code into single lines. It currently has 18 lines of code. Without counting  
// empty lines, can you get the number of lines down to 8?

 function curveGrades() {
    let sum = (accumulator, currentValue) => accumulator + currentValue

    let sumGrades = array => array.reduce(sum)

    const aryGrades = convertArray(document.querySelector('#scores'))

    var minGrade = aryGrades.reduce((a, b) => Math.min(a, b))
    
    var maxGrade = aryGrades.reduce((a, b) => Math.max(a, b))
    
    mean = sumGrades(aryGrades) / aryGrades.length

    var range = maxGrade - minGrade

    gradeSlice = range / 5

    aryGrades.forEach(applyBell)

    output.innerHTML=aryGrades

    // write the value of aryGrades to the grades div in the HTML document
}

Well i gave it a good edit. I think i got it figured out but not sure where the reduction can be to get it to 8 or if i got any of the scope things right



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source