====== Introduction to JavaScript Workshop ======
===== hello world =====
{{:pasted:20240629-225914.png}}
https://www.memecreator.org/static/images/memes/4349871.jpg
console.log('hello world!')
===== calculator =====
===== mess with images on a webpage =====
function replaceImagesWithUrl(url) {
// Get all img elements in the document
var images = document.getElementsByTagName('img');
// Convert images NodeList to an array and iterate using forEach
Array.from(images).forEach(function(img) {
// Replace the src attribute with the provided URL
img.src = url;
});
}
===== mess with text on a webpage =====
function replaceSpanText(newText) {
// Get all span elements in the document
var spans = document.getElementsByTagName('span');
// Convert NodeList to an array and iterate using forEach
Array.from(spans).forEach(function(span) {
// Replace the text content of the span with the provided new text (string
span.textContent = newText;
});
}
===== remember: =====
{{:pasted:20240629-225628.png}}
https://i.imgflip.com/5syjfo.png?a476952
===== p5js =====
https://editor.p5js.org/
===== term dump =====
( ) parentheses, brackets
{ } curly brackets, curly braces
' ' single quotes
" " double quotes
, comma
. period, dot
- dash, hyphen
_ underscore
/ slash
\ backslash
argument = the input to a function
call a function = use a function, make it do what it's intended to do
put the argument between the parentheses when you call a function
declare a function
return = the value that a function returns or gives back when it is called
string = text data which is determined by a pair of quotes, single or double
variable = a box with a name in which we can store things