JSFiddle - React, Tailwind, and code Playground

by ronnjoe

JavaScript

function johnMary(str) {
  // Your code goes here
   var stringJohn = (str.includes("john")) ?((str.match(/john/ig)).length):0;
   
  var stringMary =  (str.includes("Mary")) ?((str.match(/Mary/ig)).length):0; 
  
  return ((stringJohn) && (stringMary) && (stringJohn===stringMary))?true:false;
  
}

console.log(johnMary("&Mary&john&"));