Ad

more readable with right space between elements

Code
Diff
  • const countVowel = s => (s.match(/[aeiou]/ig) || []).length
      
    • const countVowel=s=>(s.match(/[aeiou]/ig) || []).length
    • const countVowel = s => (s.match(/[aeiou]/ig) || []).length

no need to write values in hexa. now is more readable

Code
Diff
  • isEven = _0x55bac8 => _0x55bac8 % 2 == 0 ;
    • isEven = _0x55bac8 => _0x55bac8 % 0x2 === 0x0 ;
    • isEven = _0x55bac8 => _0x55bac8 % 2 == 0 ;

the default value of a string is always null.
the variables in method are local and they will be not used anyway.

Code
Diff
  • namespace Test {
      public class Test {
        public string a, b;
        
        public bool DummyMethod() 
        {  
          return true;      
        }
        
      }
    }
    • namespace Test {
    • public class Test {
    • public string a, b;
    • public bool DummyMethod()
    • {
    • string local_a = default;
    • return local_a ==null;
    • return true;
    • }
    • }
    • }

clearing the text with space

Code
Diff
  • isEven = _0x55bac8 => _0x55bac8 % 0x2 === 0x0 ;
    • isEven=_0x55bac8=>_0x55bac8%0x2===0x0;
    • isEven = _0x55bac8 => _0x55bac8 % 0x2 === 0x0 ;

no need to variable local_b

Code
Diff
  • namespace Test {
      public class Test {
        public string a, b;
        
        public bool DummyMethod() 
        {  
          string local_a = default;     
          return local_a ==null;      
        }
        
      }
    }
    • namespace Test {
    • public class Test {
    • public string a, b;
    • public bool DummyMethod()
    • {
    • string local_b, local_a = default;
    • local_b = null;
    • return local_a == local_b;
    • string local_a = default;
    • return local_a ==null;
    • }
    • }
    • }

instead of lots of return there is only one return

Code
Diff
  • public class FizzBuzz 
    {
      public string GetOutput(int number) =>(number % 3 ==0)? ((number % 5 == 0)? "FizzBuzz":"Fizz"):(number % 5 == 0 ? "Buzz":number.ToString());
     }   
    • public class FizzBuzz {public string GetOutput(int number){if (number%3==0&&number%5==0){return"FizzBuzz";}if(number%3==0){return "Fizz";}if(number%5==0){return "Buzz";}return number.ToString();}}
    • public class FizzBuzz
    • {
    • public string GetOutput(int number) =>(number % 3 ==0)? ((number % 5 == 0)? "FizzBuzz":"Fizz"):(number % 5 == 0 ? "Buzz":number.ToString());
    • }

the string values are not used in code.

Code
Diff
  • using System.Collections.Generic;
    using System.Diagnostics;
    
    public class TowerOfHanoi
    {
        public static int Tower(int numOfDisks)
        {
          //only numOfDisks is given, fill in the other gaps, call the other method that moves disks, and return the return statement from the other method
          return Tower(numOfDisks, new Dictionary<int, int>());
        }
    
        private static int Tower(int n, Dictionary<int, int> cache)
        {
          //dictionary has keys and values.
           if (n > 0) // if one or more disks
            {
              if (cache.ContainsKey(n)) //check if dictionary contains an element with the specified key
              {
                  return cache[n]; 
              }
              //variable declared at method scope
              //outcome will be the number of moves in test
              var outcome = Tower(n - 1, cache); //move disk from rod to rod using recursion
              outcome += Tower(n - 1, cache); 
              outcome += 1;
              cache.Add(n, outcome); 
              return outcome; 
            }
            else { //if no disks given, no moves possible
              return 0;
            }
        }
    }
    
    //mathematical way to calculate moves
    //using System;
    //static int moves = 0;
    //method body
    // return moves = (int) Math.Pow(2,numOfDisks)-1;
    • using System.Collections.Generic;
    • using System.Diagnostics;
    • public class TowerOfHanoi
    • {
    • public static int Tower(int numOfDisks)
    • {
    • //only numOfDisks is given, fill in the other gaps, call the other method that moves disks, and return the return statement from the other method
    • return Tower(numOfDisks, "source", "aux", "dest", new Dictionary<int, int>());
    • return Tower(numOfDisks, new Dictionary<int, int>());
    • }
    • private static int Tower(int n, string source, string aux, string dest, Dictionary<int, int> cache)
    • private static int Tower(int n, Dictionary<int, int> cache)
    • {
    • //dictionary has keys and values.
    • if (n > 0) // if one or more disks
    • {
    • if (cache.ContainsKey(n)) //check if dictionary contains an element with the specified key
    • {
    • return cache[n];
    • }
    • //variable declared at method scope
    • //outcome will be the number of moves in test
    • var outcome = Tower(n - 1, source, aux, dest, cache); //move disk from rod to rod using recursion
    • outcome += Tower(n - 1, aux, dest, source, cache);
    • var outcome = Tower(n - 1, cache); //move disk from rod to rod using recursion
    • outcome += Tower(n - 1, cache);
    • outcome += 1;
    • cache.Add(n, outcome);
    • return outcome;
    • }
    • else { //if no disks given, no moves possible
    • return 0;
    • }
    • }
    • }
    • //mathematical way to calculate moves
    • //using System;
    • //static int moves = 0;
    • //method body
    • // return moves = (int) Math.Pow(2,numOfDisks)-1;
Code
Diff
  • namespace Test {
      public class Test {
        public string a,b = null;
        
        public bool DummyMethod() {
          
          string local_b, local_a = default;
          local_b = null;     
          return local_a == local_b;      
        }
        
      }
    }
    • namespace Test {
    • public class Test {
    • public string a;
    • public string b = null;
    • public string a,b = null;
    • public bool DummyMethod() {
    • string local_a = default;
    • string local_b = null;
    • string local_b, local_a = default;
    • local_b = null;
    • return local_a == local_b;
    • }
    • }
    • }