Help with my code

Hello everyone. I’m new here and new to coding in general. I need some help with this random bit of code I was playing around with during my practice. I cant figure out why I cant add both of my two integers. Could someone please help me?

Hello and welcome,

in Dart you can at the same time declare a variable and assign a value to it,
like in:

int bow = 10;
int arrow = 1;

You dont have to put type declarations in expressions like

int sum = bow + arrow;

You can use them to declare the types of a function’s arguments, but you also can omit them i.e.

int sumOfTwoIntegers(int arrow, int bow) {
  int result = arrow + bow;
  return result;

// omitting argument's types declarations the function works as the previous one
int sumOfTwoIntegers(arrow, bow) {
  int result = arrow + bow;
  return result;

But you do not use them when calling the function itself:

int a = 40;
int b = 2;
int j = sumOfTwoIntegers(a, b);



:exploding_head: :exploding_head:
Thank you!! I couldn’t understand for the life of me where I had went wrong in such little time?!

1 Like