If you do an if-else statement, you should not include another parenthesis with a statement to evaluate after “else”. If you do want to make sure avB is bigger than avA though, you should make it an “else if” statement. Does that make sense?
I have tried 10+ different things to try to get it to go!
This code doesn’t work either
let avA = 6 //dolphinsAverage
let avB = 2 //koalasAverage
const findWinner = function findWinner (avA,avB){
if (avA > avB) {
console.log (`a is winner`);
} else
{
console.log (`b is winner`);
}
}
In this example, you’re declaring a variable as a function with a name. You’re basically declaring it twice in two different ways.
Either declare it as a variable = function (paramaters) {code}, or declare it directly as a function, ie. function findWinner (parameters) {code}.
let avA = 6 //dolphinsAverage
let avB = 2 //koalasAverage
function findWinner (avA,avB){
if (avA > avB) {
console.log (`a is winner`);
} else
{
console.log (`b is winner`);
}
}
maybe you are not aware that for function to execute, you must call it. So far you only declared what it should do when its called. To make the function execute you call it by functionName()