start .
me .
HTML Document File : lezione-02-19.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lezione 19 Febbraio</title>
<base href="https://arkenidar.com">
<link rel="stylesheet" href="/sitewide.css"><script src="/web/dhtml/color-theme/colors.js"></script>
</head>
<body>
<div>Lezione 19 Febbraio</div> <br>
<div>printJSON(myMap([1, 2, 3], x => 2 * x))</div>
<div id="consoleOutput"></div> <br>
<script src="/web/html-console.js"></script>
<script type="module">
var htmlConsole = HTMLConsole(document.querySelector("#consoleOutput"))
htmlConsole.outputLine("example: function keyword and related.")
function nome1(x) { return x * 2 }
var nome2 = function (x) { return x * 2 }
var nome3 = x => x * 2
var sequenza = [1, 2, 3].map(nome3)
function printJSON(what) { htmlConsole.outputLine(JSON.stringify(what)) }
printJSON(sequenza)
printJSON(myMap([1, 2, 3], x => 2 * x))
function addNTimes(nTimes, what) {
if (nTimes <= 0) return
var accumulates = what
while (--nTimes) accumulates += what
return accumulates
}
htmlConsole.outputText("addNTimes(3, 'X') ")
printJSON(addNTimes(3, 'X'))
htmlConsole.outputText("addNTimes(3, 2) ")
printJSON(addNTimes(3, 2))
function myMap(inputSequence, functionEach) {
var outputSequence = []
for (var eachOne of inputSequence)
outputSequence.push(functionEach(eachOne))
return outputSequence
}
</script>
<div><a href="/web/corso-web-2024"> vai alla directory corrente. </a></div> <br>
<script src="/web/show-source.js" data-href="/web/corso-web-2024/lezione-02-19.html"></script>
<script src="/web/show-source.js" data-href="/web/html-console.js"></script>
</body>
</html>