7 kyu

Debug Basic Calculator

1,736 of 4,627Fosna

Description:

Debug a function called calculate that takes 3 values. The first and third values are numbers. The second value is a character. If the character is "+" , "-", "*", or "/", the function will return the result of the corresponding mathematical function on the two numbers. If the string is not one of the specified characters, the function should return null.

calculate(2,"+", 4); //Should return 6
calculate(6,"-", 1.5); //Should return 4.5
calculate(-4,"*", 8); //Should return -32
calculate(49,"/", -7); //Should return -7
calculate(8,"m", 2); //Should return null
calculate(4,"/",0) //should return null

Kind of a fork (not steal :)) of Basic Calculator kata by TheDoctor.

Fundamentals
Debugging

Stats:

CreatedNov 1, 2015
PublishedNov 1, 2015
Warriors Trained5955
Total Skips89
Total Code Submissions14560
Total Times Completed4627
JavaScript Completions2752
Python Completions1736
Ruby Completions238
Total Stars40
% of votes with a positive feedback rating91% of 903
Total "Very Satisfied" Votes765
Total "Somewhat Satisfied" Votes118
Total "Not Satisfied" Votes20
Ad
Contributors
  • Fosna Avatar
  • GiacomoSorbi Avatar
  • Souzooka Avatar
  • FArekkusu Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad