JSFiddle - React, Tailwind, and code Playground
by SwampFall
HTML
<input value="Insert text here?" id='input'/>
<button id='button'>
Insert text here
</button>
<div id='output'>
output will be here :3
</div>
<b>hi</b>
CSS
if (x == 5) {
// this code will run when x is 5
} else {
// this code will run when x is not 5
}
so now the condition looks a bit weird bc you don't have == in there
that's bc startsWith is a function that gives back "true" or "false", so it's already a condition
you got some time left? :3 or time to sleep? :3
next time we gonna do some more fun stuff then :3
so basically all you need to remember from today is that
- the order of code matters
- you can simplify things to think about the logic
- if statement exists (if you know it exists you can always google it easily :3)
- oh maybe how to assign variables
- and how to sleep :3
good night, god natt, slaapwel, goeienacht :3
JavaScript
let output = document.getElementById('output');
let input = document.getElementById('input');
let button = document.getElementById('button');
button.addEventListener('click', click);
function click() {
/* output.innerHTML = input.value;
input.value="text?"; */
// if (input.value.startsWith('hi')) {
if (input.value == "offered food") {
output.innerHTML = "take food"
} else {
output.innerHTML = "do nothing"
}
}