JSFiddle - React, Tailwind, and code Playground

by Ramya Ranganathan

HTML

<div id="Add"></div>

<div id='console0'>
</div>

<div id="Number to Increment"></div>

<div id="Increment"></div>

<div id='console'>
</div>

<div id="FindSquareRoot"></div>

<div id='console1'>
</div>

<div id="StringLength"></div>

JavaScript

var val1 = 5;
var val2 = 2;

 //check that they are integers, otherwise make them zero
 val1 = (parseInt(val1) ? parseInt(val1) : 0);
 val2 = (parseInt(val2) ? parseInt(val2) : 0);
 
// add Two Numbers
var total = val1 + val2

document.getElementById('Add').innerHTML = total;

/////////////////////////////////////////////////////////////

var jsFiddleConsole = function() {
    return({
        log: function(msg) {
          consoleDiv = document.getElementById('console0');
          para = document.createElement('p');
          text = document.createTextNode(msg);
          para.appendChild(text);
          consoleDiv.appendChild(para);
        }
    });
}();

////////////////////////////////////////////////////////////

var a = Number(prompt("Enter a Number to Increment by 1"));

a++
   
b = a

jsFiddleConsole.log('Input Incremented by 1: ');

document.getElementById('Increment').innerHTML = b;

/////////////////////////////////////////////////////////////

var jsFiddleConsole = function() {
    return({
        log: function(msg) {
          consoleDiv = document.getElementById('console');
          para = document.createElement('p');
          text = document.createTextNode(msg);
          para.appendChild(text);
          consoleDiv.appendChild(para);
        }
    });
}();

////////////////////////////////////////////////////////////

// Finding Square Root of a Number

var x = Number(prompt("Enter a Number to Find Square Root"));

var y = Math.sqrt(x);      // Returns the square root of Input

jsFiddleConsole.log('Square Root of Input:');

document.getElementById('FindSquareRoot').innerHTML = y;

/////////////////////////////////////////////////////////////

var jsFiddleConsole = function() {
    return({
        log: function(msg) {
          consoleDiv = document.getElementById('console1');
          para = document.createElement('p');
          text = document.createTextNode(msg);
          para.appendChild(text);
          consoleDiv.appendChild(para);
...