Ad
Games
Fundamentals
Code
Diff
  • const whoShouldServe = ($scoreLeft, $scoreRight, $servesCount) => ~~(($scoreLeft + $scoreRight) / $servesCount) % 2 === 0 ? 'first' : 'second'
    • function whoShouldServe($scoreLeft, $scoreRight, $servesCount) {
    • return ~~(($scoreLeft + $scoreRight) / $servesCount) % 2 === 0 ? 'first' : 'second';
    • };
    • const whoShouldServe = ($scoreLeft, $scoreRight, $servesCount) => ~~(($scoreLeft + $scoreRight) / $servesCount) % 2 === 0 ? 'first' : 'second'
Code
Diff
  • function prime_checker(n) {
    	if (n <= 1) return false
    	for (let i = 2; i <= Math.sqrt(n); i++) {
    		if (n % i == 0) return false
    	}
    	return true
    }
    • function prime_checker(n)
    • {
    • if(n <= 1)
    • {
    • return false;
    • }
    • for(var i = 2; i <= Math.sqrt(n); i++)
    • {
    • if(n%i == 0)
    • {
    • return false;
    • }
    • }
    • return true;
    • function prime_checker(n) {
    • if (n <= 1) return false
    • for (let i = 2; i <= Math.sqrt(n); i++) {
    • if (n % i == 0) return false
    • }
    • return true
    • }
Code
Diff
  • const removeEveryThird =  str => (str[0] || '') + str.slice(1).replace(/(..)./g, '$1')
    • function removeEveryThird(str) {
    • return (str[0] || '') + str
    • .slice(1)
    • .replace(/(..)./g, '$1')
    • }
    • const removeEveryThird = str => (str[0] || '') + str.slice(1).replace(/(..)./g, '$1')
Code
Diff
  • const greetings = () => 'My name is: seraph776'
    • function greetings(){
    • return 'My name is: seraph776'
    • }
    • const greetings = () => 'My name is: seraph776'
Strings
Parsing
Code
Diff
  • const stripEnds = (s, prefix, suffix) => s.replace(new RegExp(`[${prefix}${suffix}]`, 'gi'), '')
    
    • function stripEnds(s, prefix, suffix) {
    • return s.replace(new RegExp(`[${prefix}${suffix}]`, 'gi'), '');
    • }
    • const stripEnds = (s, prefix, suffix) => s.replace(new RegExp(`[${prefix}${suffix}]`, 'gi'), '')