diff --git a/script.js b/script.js index 6582e0d..589dbbe 100644 --- a/script.js +++ b/script.js @@ -1,11 +1,37 @@ -console.log("hello script js"); +console.log("DRAW THIS THROUGH DOM MANIPULATION!"); -var inputHappened = function(currentInput){ - console.log( currentInput ); - display( "WOW SOMETHING HAPPENED" ); -}; +function clearInput() { + document.getElementById("input").value = ""; +} + +var fruit = "🍍"; +var storeInput = 0; +var showOutput = ""; -var display = function(stuffToDisplay){ - // your DOM manipulation code here - +var inputHappened = function(currentInput) { + var storeInput = currentInput; + clearInput(); + console.log(storeInput); + if (!isNaN(parseInt(storeInput)) && storeInput < 10) { + for (i = 0; i < storeInput; i++) { + showOutput = showOutput + fruit; + console.log(showOutput); + } + var display = document.createElement("p"); + display.innerText = showOutput; + document.getElementById("output").appendChild(display); + showOutput = ""; + } else if (!isNaN(parseInt(storeInput)) && storeInput > 9) { + var display = document.createElement("p"); + display.innerText = "Value entered is too big! Please Enter 1 - 9 only"; + document.getElementById("output").appendChild(display); + } else if (storeInput === "clear") { + console.log("hello this is working!"); + document.querySelector("#output").textContent = ""; + } else { + document.querySelector("#output").textContent = + "Please enter only numbers!"; + } }; + +//Part 1 completed//