Skip to content
Sign upLog in
← Back to Community

assignment 2 is confusing

Profile icon
StrayLove

it says here
// In this exercise, you will be given two variables, they will be called: num1 and num2
// On the next line create a variable called 'difference' and using math operators return num2 subrtracted from num1
const difference = num1 - num2;
do_math(num1, num2);
// Please write your answer in the line above.
return difference;
}
i am just not getting this whole excercise. tbh the video wasnt explaining that much either. im feeling awful confused

Voters
Profile icon
eahenkorah
Profile icon
Mahalia25
Profile icon
StrayLove
Comments
hotnewtop
Profile icon
vedprad1

First of all you are missing the start of the function, with the name and the parameters. You can't do anything without that.
Second of all, if you have a do_math() function, you do not need it. If you don't have it, you can;t use it. Delete that line.

Your final answer should look like this:

function exerciseTwo(num1, num2) { var difference = num1 - num2; return difference; }

If this answers your question, please check the checkmark on the left side of this message. Thanks and Good Luck!

I don't know how your teacher grades your answers, but wouldn't it be simpler if you did this?

function exerciseTwo(num1, num2) { return num1 - num2; }
Profile icon
JuanCDean45

Hello friends, Literally I love this page very much because from this page I have improved the coding of my assignments. I used to get confused in writing most of the assignments. I shared this thing with my uncle. Uncle suggested this page https://domyassignmentsforme.com/. I saw here that I can complete my assignment from here. In the last days of my semester, I got rid of the stress of how the assignments would be.

Profile icon
StrayLove

i give up. it still says undefined no matter what i did

Profile icon
StrayLove

original syntax for the exercise looked like the following, i have no do math stuff on the exercise anywhere. i have tried several times to find the answer but it keeps saying undefined. i even looked up how to do it. ugh.

function exampleExercise(num1, num2){
// !!! This is an example exercise, we will show you how to complete the following exercises here.
// !!! There is NO need to write any code for this exercise.
// !!! This exercise ia ALREADY complete, Use this as reference to complete the others.

// In this exercise, you will be given two variables, they will be called: num1 and num2
// On the next line create a variable called 'difference' and using math operators return num2 subrtracted from num1
const difference = num1 - num2;

// Please write your answer in the line above.
return difference;
}

Profile icon
vedprad1

@StrayLove
: It says that you do not need to do anything. Literally, the answer is provided:

const difference = num1 - num2;

If this answers your question, please check the checkmark on the left side of this message. Thanks and Good Luck!

Profile icon
Vandesm14

What are you confused on? The variable "difference" is set to num1 - num2. The function "do_math()" is a single line function, which executes and returns "difference" which is num1 - num2.

Wrapping it up: do_math will return the difference of num1 and num2.

For your error, you are setting a permanent value to the variable "difference". Instead of const, use var to declare a changeable value.

Please mark this as answered if I helped your problem

Profile icon
StrayLove

@Vandesm14
that const value was already there when i opened the lesson. so i had no idea. the whole lesson is preset like the second example i gave you. and tyvm for all your help btw.