How to write above code in return the number of total permutations?

  • Return the number of total permutations of the provided string that don’t have repeated consecutive letters. Assume that all characters in the provided string are each unique.

function permAlone(str) {
return str;

It should contains

  • permAlone("aab") should return a number.

  • permAlone("aab") should return 2.

  • permAlone("aaa") should return 0.

  • permAlone("aabb") should return 8.

  • permAlone("abcdefa") should return 3600.

  • permAlone("abfdefa") should return 2640.

  • permAlone("zzzzzzzz") should return 0.

  • permAlone("a") should return 1.

  • permAlone("aaab") should return 0.

  • permAlone("aaabb") should return 12.

I don’t think anyone here is just going to write this for you. Maybe if you showed us what you have tried so far we will offer suggestions.