JSFiddle - React, Tailwind, and code Playground

by Jordan Marechal

JavaScript

var putAnXBtn {
document.getElementById("putAnXButton");
     
 	// get a reference to the box
        var theBox = document.getElementById("putAnX");
        
        // now get the width and height of the box - see the clientWidth and clientHeight documentation at http://docs.webplatform.org/wiki/dom/HTMLElement
        var resultY = element.clientHeight;
            element.clientHeight = value;
    var height = theBox.clientHeight;
    
        var resultX = element.clientWidth;
            element.clientWidth = value;
        var width = theBox.clientWidth;
        

        //function onclick(e);{
           // var resultY= document.getElementById("putAnX").innerHTML = Math.random();
            //xPosition.innerHTML = Math.floor((Math.random() * 100) + 0);
       // }
        // *   Now, here's where you do your magic. The xPosition and yPosition should not be set to zero.
       //  function onclick(e); {
           // var resultX = document.getElementById("putAnX").innerHTML = Math.random();
           // yPosition.innerHTML = Math.floor((Math.random() * 100) + 0);
      //  }
        // *   Use the Math.random() function to get a number between
       //  *   0 and 1, then use some math to convert that to a number between 0 and the width. This is your x position.
        // *
        // *   Do the same thing to generate a number between 0 and the height: this is your y position.
       //  *   */
 //function onclick(e) {
        var yPosition = Vdocument.getElementById("putAnX").innerHTML = Math.random();
            xPosition.innerHTML = Math.floor((Math.random() * 100) + 0);// should generate a value between 0 and the height
     
        var xPosition = document.getElementById("putAnX").innerHTML = Math.random();
            yPosition.innerHTML = Math.floor((Math.random() * 100) + 0);  //should generate a value between 0 and the width
 
 	//now we'll get the HTML element where the X goes, fill in the X and set the position of the element.
 	var...