Ad

I think it is too odd when one have to use IF to return TRUE or FALSE... So I explictly converted the value to boolean and returned it, bypassing an unwanted if statement.

That said, I noticed that this does not cover when a property's value can be zero or FALSE.

As you consider '' as an unwanted value, I suppose the same goes for 0 and FALSE, which I think is an odd thing to assume.

Code
Diff
  • function validateProperty(objectForValidate, specificProperty) {
      return Boolean(objectForValidate[specificProperty]);
    }
    • function validateProperty(objectForValidate, specificProperty) {
    • if(objectForValidate[specificProperty]){
    • return true;
    • } else{
    • return false;
    • }
    • return Boolean(objectForValidate[specificProperty]);
    • }
Fundamentals
Arrays
Data Types

The original solution did not cover for empty string.
Also, you can remove completly the sum part from the reduce as to make it simpler to read.

Code
Diff
  • const sum = (a,b) => a+b;
    const getSum = array => array.reduce(sum,0);
    • const getSum = array => array.reduce((acc, i) => acc + i)
    • const sum = (a,b) => a+b;
    • const getSum = array => array.reduce(sum,0);