Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Opposites attract

/*
// Timmy & Sarah think they are in love, but around where they live, they will only 
know once they pick a flower each. If one of the flowers has an even number of 
petals and the other has an odd number of petals it means they are in love.
// Write a function that will take the number of petals of each flower and return 
true if they are in love and false if they aren't.
*/

const lovefunc = (flower1, flower2) => {
  // More dynamic
  [flower1, flower2].filter(flower => flower % 2 === 0).length === 1
      // OR
  (flower1 + flower2) % 2 === 1
}

// With love @kouqhar
Comment

PREVIOUS NEXT
Code Example
Javascript :: nodejs where multiple condition findAll 
Javascript :: after end time run function 
Javascript :: js undici 
Javascript :: angular reactive forms bootstrap 4 
Javascript :: check notification permissopn allow or not 
Javascript :: Count the number of child records on the each parent object 
Javascript :: getauth firebase admin node.js 
Javascript :: why cant i add to object mongoose 
Javascript :: mongo db backup node js daily 
Javascript :: Using the forEach function In JavaScript 
Javascript :: react native geolocation 
Javascript :: javascript prompts user to input 
Javascript :: empty array javascript 
Javascript :: javascript filter example 
Javascript :: how to do a function after a set interval js 
Javascript :: for in loop 
Javascript :: printing in javascript 
Javascript :: parse query url javascript 
Javascript :: fuzzy search javascript 
Javascript :: javascript document get by attribute 
Javascript :: javascript.loop 
Javascript :: how to log all messages discord.js 
Javascript :: js Destructuring in React 
Javascript :: Javascript print/output 
Javascript :: parse json java 
Javascript :: how to get a random item from an array javascript 
Javascript :: socket io get user rooms 
Javascript :: Javascript: 
Javascript :: hasOwnProperty.call js 
Javascript :: javascript linting 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =