Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Rules: </h1>
<ul>
<li>Type one number or "clear", otherwise it will not work</li>
<li>Type "3 2" whereas 3 stands for amount of input while 2 stands for the number of paragraph.</li>
<li>Type "clear 2" whereas 2 represent which line of paragraph you would like to delete</li>
<li>Try "triangle/rtriangle 4"</li>
</ul>
<input class="starter" id="input" placeholder="input"/>
<h2>output:</h2>
<p class="starter" id="output"></p>
Expand Down
87 changes: 80 additions & 7 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,84 @@
console.log("hello script js");
var flagHolder = [];
var inputArray = [];
//var emojiList = ["🏁","🎲","♟","🎯","🎖"]

var inputHappened = function(currentInput){
console.log( currentInput );
display( "WOW SOMETHING HAPPENED" );
//validation
while (
((choice = prompt("What will be the emoji you would like to draw with?")),
choice.length !== 2 && choice.length !== 1)
) {
alert("Type within 2 charcter or 1 emoji.");
}

var inputHappened = function (currentInput) {
inputArray = currentInput.split(" ");

//1 number only
if (inputArray.length === 1) {
var flagLength = parseInt(inputArray[0]);

//clear
if (inputArray[0].toLowerCase() === "clear") {
document.querySelector("#output").innerHTML = "";
}
else if (inputArray[0] > 0) {
for (let i = 0; i < flagLength; i++) {
flagHolder.push(choice);
}
display();
flagHolder = [];
}
}

if (inputArray.length === 2) {
var firstNum = parseInt(inputArray[0]);
var paragraph = parseInt(inputArray[1]);

//remove one paragraph
if (inputArray[0].toLowerCase() === "clear" && inputArray[1] > 0) {
document.querySelectorAll("p")[paragraph].remove();
}

//check no. of input and paragraph
else if (firstNum > 0 && inputArray[1] > 0) {
for (let i = 0; i < firstNum; i++) {
flagHolder.push(choice);
}
for (let j = 0; j < paragraph; j++) {
display();
}
flagHolder = [];
}

else if (inputArray[0].toLowerCase() === "triangle" && inputArray[1] > 0) {
for (let j = 0; j < paragraph; j++) {
flagHolder.push(choice)
display();
}
flagHolder = [];
}

else if (inputArray[0].toLowerCase() === "rtriangle" && inputArray[1] > 0) {
for (let j = 0; j < paragraph; j++) {
flagHolder.push(choice)
var output = document.querySelector("#output");
var createP = document.createElement("p");
let htmlSpace = "&nbsp;&nbsp;&nbsp;&nbsp;";
let spaceRepeat = htmlSpace.repeat(inputArray[1]-(j+1));
createP.innerHTML = spaceRepeat+flagHolder.join("");
output.appendChild(createP);
}
flagHolder = [];
}
}
//clear the input
document.querySelector("#input").value = "";
};

var display = function(stuffToDisplay){
var display = function (stuffToDisplay) {
// your DOM manipulation code here

};
var output = document.querySelector("#output");
var createP = document.createElement("p");
createP.innerHTML = flagHolder.join("");
output.appendChild(createP);
};