DEV Community

Madalina Pastiu
Madalina Pastiu

Posted on

#1 School Paperwork

Instructions:

Your classmates asked you to copy some paperwork for them. You know that there are 'n' classmates and the paperwork has 'm' pages.

Your task is to calculate how many blank pages do you need. If n < 0 or m < 0 return 0.

Example:
n= 5, m=5: 25
n=-5, m=5: 0

Solution:

function paperwork(n, m) {
  if(n<0 || m<0) return 0;
  return n*m;
}
Enter fullscreen mode Exit fullscreen mode

Thoughts:

1.I do create an if statement to verify any of the conditions imposed by instructions.If any of the conditions are met is returning 0 otherwise the return is m*n.

This is a CodeWars Challenge of 8kyu Rank

Top comments (0)