Exercise 9- Grade

Hello Everyone
I need some help,

here is my code which works ok ,

const student1 = [100,80,100,90];
function calculateGrade(student1){
     let sum = 0 ;
     let average = 0 ;
     for ( let points of student1)
        sum += points;
        console.log("this is the total points", sum)
            average = (sum / student1.length) ;
        console.log("Your Average is ", average);
           
        if (average < 60)  
            console.log('Your Grade Is F');
        if (average < 70) 
            console.log('Your Grade Is D');
        if (average < 80)  
            console.log('Your Grade Is C');
        if (average < 60)
            console.log('Your Grade Is B');
        else
            console.log ('Your Grade Is A');
    };

but I have some questions since we didn’t go over it enough;

when should we use return and when we should console.log()?
since every practice has a different method its is hard for me to understand that.

did we go over one function inside another function? if we did please let me know which one it is.

and what if we don’t have const mark at all? for example something else like Mosh?

also what is difference between var and let?

The console.log statement is something you use when debugging, or like in this case learning to code. It’s an easy way to show the result of some code.

The return statement returns a value from a function. When the return is executed the function stops.

Your question about function inside another function I don’t understand. I see only one function declared (= calculateGrade).

Difference between const, let and var: