JavaScript Array flatMap() method JavaScript Array flatMap() Method is used to transform each element of an array and flatten the resulting…