# Write a program to console all 2-digits twisted prime numbers in JavaScript?

A number is twisted prime if it is a prime number and reverse of the number is also a prime number. for example. 11, 13, 17 etc.

```

function reverse(  n:number)
{
let rev = 0, r=0;
while (n > 0) {
r = n % 10;
rev = rev * 10 + r;
n /= 10;
}
return rev;
}

function reverseNumber(num:number)
{

var n= num;
var rev = 0, rem;
while (n>0)
{
rem = n % 10;
rev = rev * 10 + rem ;
n = Math.floor(n/10);
}

return rev;

}

// Returns true if n is prime
function isPrimeNumber( n:number )
{
// return false is if value is one
if (n <= 1)
return false;
if (n <= 3)  // return true if value is 2
return true;

// check the number is divided by 2 or 3 and return the false

if (n % 2 == 0 || n % 3 == 0)
return false;

//
for (var i = 5; i * i <= n; i = i + 6)
if (n % i == 0 || n % (i + 2) == 0)
return false;

return true;
}

// let isPrimeNumberResult = isPrimeNumber(97);
// console.log(isPrimeNumberResult);

function isTwistedPrimeNumber(value:number ) : boolean {

// first check passed number is prime or not. If not then return the false.
if(isPrimeNumber(value) == false )
{
return false ;
}
// reverse the number and check the reverse number is prime number or not
if(isPrimeNumber(reverseNumber(value)) == true)
{
return true ;
}
else {
return false ;
}

}

// console all the two digit twisted prime numbers
function printTwistedPrimeNumberOf2Digits(){

for (let index = 11; index <=99; index++) {

if(isTwistedPrimeNumber(index)){
console.log(index);
}
}
}

printTwistedPrimeNumberOf2Digits();

```