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
39 changes: 22 additions & 17 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="style.css">
</head>
<body>
<input class="starter" id="input" placeholder="input"/>
<h2>output:</h2>
<p class="starter" id="output"></p>
<script>
document.querySelector('#input').addEventListener('change', function(event){
var currentInput = event.target.value;
inputHappened(currentInput)
});

</script>
<script src="script.js"></script>
</body>
</html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="style.css">
</head>

<body>
<input class="starter" id="input" placeholder="input" />
<h2>output:</h2>

<p class="starter" id="output"></p>


<!-- <script>
document.querySelector('#input').addEventListener('change', function (event) {
var currentInput = event.target.value;
inputHappened(currentInput)
});
</script> -->
<script src="script.js"></script>
</body>

</html>
70 changes: 61 additions & 9 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,63 @@
console.log("hello script js");
// console.log("hello script js");

var inputHappened = function(currentInput){
console.log( currentInput );
display( "WOW SOMETHING HAPPENED" );
};
// var inputHappened = function (currentInput) {
// console.log(currentInput);
// display("WOW SOMETHING HAPPENED");
// };

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

};


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

// };


/* Version 1 */
const input = document.querySelector('#input');
const output = document.querySelector('#output');

const newContent = document.createElement('div'.id = 'content');
document.body.appendChild(newContent);
newContent.appendChild(output);

input.addEventListener('change', event => {

const currentInput = event.target.value;

switch (currentInput) {
case '3':
output.innerHTML = `<p>🍍🍍🍍</p>`;
break;
case '2':
output.innerHTML += `<p>🍍🍍</p>`;
break;
/* Version 2 */
case '2 2':
output.innerHTML = `<p>🍍🍍<br>🍍🍍</p>`;
break;

default:
output.innerHTML += `<p>`;
for (let i = 0; i < (parseInt(currentInput) || 1); i++) {
output.innerHTML += `🍍`;
}
output.innerHTML += `</p>`;
break;

case 'clear':
output.innerHTML = '';
break;

/* further try */
case 'triangle 3':
output.innerHTML = `<p>🍍🍍🍍<br>🍍🍍<br>🍍</p>`;
break;

case 'rtriangle 3':
output.innerHTML = `<p style='text-align: right'>🍍<br>🍍🍍<br>🍍🍍🍍</p>`;
break;
}
});

/* Version 2 */