Slideshow JavaScript

slideshow javascript

In questa lezione sviluppiamo un semplice slideshow in JavaScript. Gli slideshow di immagini sono un modo efficace ed accattivante per presentare visivamente un sito web. È superfluo quindi evidenziare che occorre selezionare foto di alta qualità, ben illuminate e nitide e di forte impatto visivo. L’obiettivo è quello di raccontare la storia attraverso le immagini, … Leggi tutto

Gioco dell’impiccato in JavaScript

Gioco dell’impiccato in JavaScript

In questa lezione propongo il gioco dell’impiccato in JavaScript, uno dei passatempi più noti e accessibili a tutti. Difatti, le regole del gioco dell’impiccato sono abbastanza semplici e divertenti. Il gioco dell’impiccato è un classico passatempo che può essere giocato anche da una sola persona oppure in gruppo. Potete innanzitutto provare a giocare alla variante … Leggi tutto

Gioco indovina numero in JavaScript con il DOM

libro javascript

In questa lezione svilupperemo il gioco indovina numero in JavaScript utilizzando il DOM. Il gioco “Indovina il Numero” è un gioco interattivo in cui l’utente ha l’obiettivo di indovinare un numero segreto generato casualmente dal computer. Il gioco da realizzare sarà dunque simile a questo: Gioca! Prova il gioco inserendo il numero da indovinare nella … Leggi tutto

JavaScript: Operatori Aritmetici e Incremento/Decremento

Quando impari JavaScript, uno dei concetti più importanti riguarda gli operatori aritmetici e le modalità di incremento e decremento delle variabili. In questo articolo vedremo esempi pratici, spiegazioni dettagliate e un piccolo esercizio per mettere alla prova le tue conoscenze. Operatori Aritmetici in JavaScript Gli operatori aritmetici permettono di fare calcoli con numeri e variabili. … Leggi tutto

Stringhe in JavaScript: singoli apici, doppi apici e backtick

In JavaScript, le stringhe (testi) possono essere scritte in tre modi diversi: Apici singoli ‘…’ Stampare una variabile: Doppi apici “…” Stampare una variabile: Backtick `…` (template literal) 🔹 Sintesi rapida Tipo di apice Quando usarlo Vantaggi ‘…’ Stringhe semplici Sintassi pulita, compatibile ovunque “…” Stringhe semplici Alternativa agli apici singoli `…` Template literal Variabili, … Leggi tutto

Variabili e Tipi di Dati in JavaScript

In JavaScript, le variabili sono contenitori per memorizzare dati. Ogni variabile ha un tipo di dato, che determina come il browser la interpreta. Dichiarazione delle variabili Esistono tre modi principali per dichiarare una variabile: Parola chiave Descrizione Scope let Variabile modificabile Block scope const Costante (non modificabile) Block scope var Variabile (da evitare) Function scope … Leggi tutto

Introduzione a JavaScript: il linguaggio che fa vivere il web

Se ti sei mai chiesto cosa rende un sito web interattivo, dinamico e divertente da usare, la risposta è quasi sempre una sola: JavaScript. È il linguaggio che lavora dietro le quinte quando clicchi un pulsante, compili un modulo, vedi un’animazione o scorri una pagina che “reagisce” alle tue azioni. In breve? JavaScript è il … Leggi tutto

Random quotes generator

random quotes generator

In this lesson we will develop a random quotes generator. We will make sure that clicking on a button, from time to time, generates a new sentence. Try the example below by clicking on the button: Random Quotes Generator Generate a new sentence Development of the random quotes generator First let’s develop the simple HTML … Leggi tutto

JavaScript projects

Progetti JavaScript

In this article we will develop some simple JavaScript projects, such as displaying a counter that is incremented in various ways. JavaScript projects – counter In this first project we will build a counter using only Vanilla JavaScript. Try clicking on the buttons below to increase or decrease the counter variable which starts from the … Leggi tutto

JavaScript isNaN

isNaN JavaScript

JavaScript isNaN function determines whether the value passed as an argument is not a number. The syntax is therefore the following: isNaN(value). The function returns a Boolean value that is true if the argument passed is not a number, otherwise it returns false. JavaScript isNaN – examples In all the examples presented under the isNaN … Leggi tutto

Fibonacci JavaScript

Successione di Fibonacci in JavaScript

In this lesson we will implement a Fibonacci sequence algorithm in JavaScript. First of all, remember that the Fibonacci sequence is a sequence of positive integers in which each number, starting with the third, is the sum of the previous two and the first two are 1, 1. So, for example if I want to … Leggi tutto

Nesting for loops

JavaScript for cicli annidati

In this lesson we talk about nesting for loops in JavaScript, with the for loop. So we will see how to use a loop inside another loop. To explain the concept of nested loop let’s try to create a table using html and javascript. Nesting for loops – table So let’s suppose we want to … Leggi tutto

JavaScript toString

toString JavaScript

JavaScript toString method is used to convert an array to a string. The array to be converted can contain any data, such as numbers, objects, strings, etc. It is usually used to converter numbers in strings. The syntax of this method is very simple: array.toString(). The toString() method therefore returns a string. Since the original … Leggi tutto

JavaScript shift and unshift

Shift e Unshift in JavaScript

With the shift and unshift methods I remove and add respectively an element at the beginning of each array in JavaScript. The syntax of these methods is as follows: array.unshift (element1, element2,…, elementN) array.shift() As we can see with the unshift method it is possible to insert more than one element between round brackets, separated … Leggi tutto

JavaScript pop

Pop JavaScript

In this lesson we will cover the pop method in JavaScript, which is useful for deleting elements in an array. In the previous lesson we have dealt with the push method and we have seen how to add elements to our queued array, now we will see how to delete them. So to remove or … Leggi tutto

JavaScript array push

Push JavaScript

In this lesson we will see how to insert data into a JavaScript array push method, useful to insert element in array. The syntax of this method is as follows: array.push(element). Where array is the name of our array we want to populate. Element represents what we want to insert in the array. You can … Leggi tutto

JavaScript array

array javascript

In JavaScript an array is a useful tool for storing multiple data even of different types. In fact, JavaScript, like other programming languages, allows the creation and management of arrays. There are various ways to define an array in JavaScript, in this tutorial we will analyze them all and see which is more congenial. JavaScript … Leggi tutto

JavaScript createElement

dom in javascript

In this lesson we study JavaScript createElement method, useful to create new elements in the DOM. In the previous article we saw how to manipulate the DOM in JavaScript and studied methods for selecting elements on a page. You can consult the article at the following link: https://www.codingcreativo.it/en/javascript-dom/. JavaScript createElement – How to create elements … Leggi tutto