JSFiddle - React, Tailwind, and code Playground

by dhizzybusy

HTML

<html>
<head>
<title>Tower Of Hanoi in JavaScript</title>
</head>
<body> <h1>Towers of Hanoi</h1>
</body>
</html>

JavaScript

var count=0;
function moveDisk( N, A, C, B)
{
if(N==1)
   count=count+1;

if ( N > 1 )
{
   moveDisk( N-1, A, B, C );
   count=count+1;
   moveDisk( N-1, B, C, A );
   }
}
//A as Source , C as Destination , B as Auxillary
var numberOfPlates=6;
moveDisk( numberOfPlates, "A", "C", "B" );
document.write( "Count = " + count );
-->