<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ca">
	<id>http://wiki.joanillo.org/index.php?action=history&amp;feed=atom&amp;title=Sintaxi_del_llenguatge_II</id>
	<title>Sintaxi del llenguatge II - Historial de revisió</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.joanillo.org/index.php?action=history&amp;feed=atom&amp;title=Sintaxi_del_llenguatge_II"/>
	<link rel="alternate" type="text/html" href="http://wiki.joanillo.org/index.php?title=Sintaxi_del_llenguatge_II&amp;action=history"/>
	<updated>2026-08-30T03:14:44Z</updated>
	<subtitle>Historial de revisió per a aquesta pàgina del wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>http://wiki.joanillo.org/index.php?title=Sintaxi_del_llenguatge_II&amp;diff=264399&amp;oldid=prev</id>
		<title>Joan a 18:15, 21 set 2020</title>
		<link rel="alternate" type="text/html" href="http://wiki.joanillo.org/index.php?title=Sintaxi_del_llenguatge_II&amp;diff=264399&amp;oldid=prev"/>
		<updated>2020-09-21T18:15:54Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ca&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Versió més antiga&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revisió del 18:15, 21 set 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l10&quot; &gt;Línia 10:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Línia 10:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*http://www.w3schools.com/&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*http://www.w3schools.com/&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;*http://www.w3schools.com/js/js_variables.asp&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*http://www.w3schools.com/js/js_datatypes.asp&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*http://www.w3schools.com/js/js_datatypes.asp&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*http://www.w3schools.com/js/js_objects.asp&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*http://www.w3schools.com/js/js_objects.asp&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Joan</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.joanillo.org/index.php?title=Sintaxi_del_llenguatge_II&amp;diff=257835&amp;oldid=prev</id>
		<title>Joan: /* Bateria d'exercicis proposats */</title>
		<link rel="alternate" type="text/html" href="http://wiki.joanillo.org/index.php?title=Sintaxi_del_llenguatge_II&amp;diff=257835&amp;oldid=prev"/>
		<updated>2018-10-02T15:20:06Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Bateria d&amp;#039;exercicis proposats&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Pàgina nova&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=Introducció=&lt;br /&gt;
Aquesta pràctica té per objectiu iniciar-se en l'aprenentatge i familiarització de la sintaxi de Javascript, i continua amb les següents pràctiques. Així mateix s'explica el procediment i la pauta que seguirem mentre s'explica la teoria i es fa la pràctica.&lt;br /&gt;
&lt;br /&gt;
El tutorial que seguirem per aprendre Javascript és el de http://www.w3schools.com/ (en anglès). En aquest tutorial, tots els exemples estan orientats a la web. El procediment que seguirem serà:&lt;br /&gt;
*el professor explicarà la teoria.&lt;br /&gt;
*els alumnes faran i provaran els exercicis proposats (en un entorn HTML). Els fitxers generats tindran doncs extensió .html.&lt;br /&gt;
*els alumnes assimilaran els conceptes i miraran d'ampliar coneixements, fer provatures,...&lt;br /&gt;
&lt;br /&gt;
=Referències=&lt;br /&gt;
*http://www.w3schools.com/&lt;br /&gt;
&lt;br /&gt;
*http://www.w3schools.com/js/js_variables.asp&lt;br /&gt;
*http://www.w3schools.com/js/js_datatypes.asp&lt;br /&gt;
*http://www.w3schools.com/js/js_objects.asp&lt;br /&gt;
*http://www.w3schools.com/js/js_functions.asp&lt;br /&gt;
*http://www.w3schools.com/js/js_operators.asp&lt;br /&gt;
*http://www.w3schools.com/js/js_comparisons.asp&lt;br /&gt;
*http://www.w3schools.com/js/js_if_else.asp&lt;br /&gt;
*http://www.w3schools.com/js/js_switch.asp&lt;br /&gt;
*http://www.w3schools.com/js/js_popup.asp&lt;br /&gt;
*http://www.w3schools.com/js/js_loop_for.asp&lt;br /&gt;
*http://www.w3schools.com/js/js_loop_while.asp&lt;br /&gt;
&lt;br /&gt;
=Desenvolupament=&lt;br /&gt;
Els alumnes provaran amb l'ordre proposat tots els exemples que s'han explicat a classe. Es genenraran els fitxers .html&lt;br /&gt;
===Exercici de classe 2-10-2017===&lt;br /&gt;
*Taules de multiplicar amb dos ''for'' 'anidats'&lt;br /&gt;
&lt;br /&gt;
*Amb if-else if, detecta ''primavera'', ''estiu'', ''tardor'' i ''hivern''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
primavera: 21 març - 20 juny&lt;br /&gt;
estiu: 21 juny - 20 set&lt;br /&gt;
tardor: 21 set - 20 des&lt;br /&gt;
hivern: 21 des - 20 mar&lt;br /&gt;
&lt;br /&gt;
var fecha = new Date();&lt;br /&gt;
dia = fecha.getDate();&lt;br /&gt;
mes=fecha.getMonth();&lt;br /&gt;
console.log(dia);&lt;br /&gt;
console.log(mes);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''solució''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ node taulamult.js&lt;br /&gt;
&lt;br /&gt;
for (var i=1;i&amp;lt;=10;i++){&lt;br /&gt;
	console.log('\nTaula del ' + i);&lt;br /&gt;
	for(var j=1;j&amp;lt;=10;j++){&lt;br /&gt;
		var res=i*j;&lt;br /&gt;
		console.log (i + '*' + j + '=' + res);&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ node estacions.js&lt;br /&gt;
 &lt;br /&gt;
//té prioritat el AND lògic sobre el OR lògic?&lt;br /&gt;
//console.log (true &amp;amp;&amp;amp; true || false );&lt;br /&gt;
//tenen la mateixa prioritat. S'opera d'esquerra a dreta.&lt;br /&gt;
&lt;br /&gt;
function decirEstacion(mes,dia){&lt;br /&gt;
	if( (mes==11 &amp;amp;&amp;amp; dia&amp;gt;=21) || mes==0 || mes==1 || (mes==2 &amp;amp;&amp;amp; dia&amp;lt;21) ) {&lt;br /&gt;
		console.log(&amp;quot;Es invierno&amp;quot;);     &lt;br /&gt;
	} else if ( (mes==2 &amp;amp;&amp;amp; dia&amp;gt;=21) || mes==3 || mes==4 || (mes==5 &amp;amp;&amp;amp; dia&amp;lt;21) ) {&lt;br /&gt;
		console.log(&amp;quot;Es primavera&amp;quot;);           &lt;br /&gt;
	} else if ( (mes==5 &amp;amp;&amp;amp; dia&amp;gt;=21) || mes==6 || mes==7 || (mes==8 &amp;amp;&amp;amp; dia&amp;lt;21) ) {&lt;br /&gt;
		console.log(&amp;quot;Es verano&amp;quot;);          &lt;br /&gt;
	} else if ((mes==8 &amp;amp;&amp;amp; dia&amp;gt;=21) || mes==9 || mes==10 || (mes==11 &amp;amp;&amp;amp; dia&amp;lt;21) ) {&lt;br /&gt;
		console.log(&amp;quot;Es otono&amp;quot;);                                                      &lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
var fecha = new Date();&lt;br /&gt;
dia = fecha.getDate();&lt;br /&gt;
mes=fecha.getMonth();&lt;br /&gt;
console.log(dia);&lt;br /&gt;
//recordar que getMonth() dóna valors de 0 a 11 (gener a desembre)&lt;br /&gt;
console.log(mes);&lt;br /&gt;
decirEstacion(mes,dia);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Exercici 2-oct-2018===&lt;br /&gt;
Donats n números (n=10, n=100, n=1000), trobar el valor més gran.&lt;br /&gt;
&lt;br /&gt;
Ha de ser una solució que et valgui tant per 10 com per 100 o 1000.&lt;br /&gt;
&lt;br /&gt;
Posarem els valors que vols comparar en una matriu.&lt;br /&gt;
&lt;br /&gt;
Solució1:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var array = [1,123,23,43,46];&lt;br /&gt;
&lt;br /&gt;
valor = array[0];&lt;br /&gt;
&lt;br /&gt;
for (var i = 0; i&amp;lt;array.length-1; i++ ) {&lt;br /&gt;
	//console.log(array[i]);&lt;br /&gt;
	if (valor&amp;lt;array[i+1]) valor = array[i+1];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
console.log (&amp;quot;El valor més gran és: &amp;quot; + valor);&lt;br /&gt;
&lt;br /&gt;
//https://www.w3schools.com/js/js_array_methods.asp&lt;br /&gt;
//Finding Max and Min Values in an Array&lt;br /&gt;
//There are no built-in functions for finding the highest or lowest value in a JavaScript array.&lt;br /&gt;
//You will learn how you solve this problem in the next chapter of this tutorial.&lt;br /&gt;
&lt;br /&gt;
//https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Objetos_globales/Math/max&lt;br /&gt;
//spread operator (...)&lt;br /&gt;
console.log(Math.max(...array));&lt;br /&gt;
&lt;br /&gt;
//https://www.w3schools.com/js/js_array_sort.asp&lt;br /&gt;
//array_ordenat = array.sort(); //ordenació alfabètica&lt;br /&gt;
array_ordenat = array.sort(function(a, b){return a - b}); //ordenació numèrica&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
console.log(array_ordenat); &lt;br /&gt;
console.log(array_ordenat[array_ordenat.length-1]); &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Solució2 (generem 1000 números aleatoris):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var array = new Array(1000);&lt;br /&gt;
//compte!! toFixed: Convert a number into a string, keeping only two decimals&lt;br /&gt;
for (var i = 0;i&amp;lt;1000;i++) {&lt;br /&gt;
	array[i] = parseFloat((Math.random()*5000).toFixed(2));&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
valor = array[0];&lt;br /&gt;
&lt;br /&gt;
console.log(typeof array[0]);&lt;br /&gt;
&lt;br /&gt;
for (var i = 0; i&amp;lt;array.length-1; i++ ) {&lt;br /&gt;
	//console.log(array[i]);&lt;br /&gt;
	if (valor&amp;lt;array[i+1]) valor = array[i+1];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
console.log (&amp;quot;El valor més gran és: &amp;quot; + valor);&lt;br /&gt;
&lt;br /&gt;
//https://www.w3schools.com/js/js_array_methods.asp&lt;br /&gt;
//Finding Max and Min Values in an Array&lt;br /&gt;
//There are no built-in functions for finding the highest or lowest value in a JavaScript array.&lt;br /&gt;
//You will learn how you solve this problem in the next chapter of this tutorial.&lt;br /&gt;
&lt;br /&gt;
//https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Objetos_globales/Math/max&lt;br /&gt;
//spread operator (...)&lt;br /&gt;
console.log(Math.max(...array));&lt;br /&gt;
&lt;br /&gt;
//https://www.w3schools.com/js/js_array_sort.asp&lt;br /&gt;
//array_ordenat = array.sort(); //ordenació alfabètica&lt;br /&gt;
array_ordenat = array.sort(function(a, b){return a - b}); //ordenació numèrica&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//console.log(array_ordenat); &lt;br /&gt;
console.log(array_ordenat[array_ordenat.length-1]); &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==Bateria d'exercicis proposats==&lt;br /&gt;
*http://www.w3resource.com/javascript-exercises/&lt;br /&gt;
(a classe veurem algun d'aquests exercicis)&lt;br /&gt;
&lt;br /&gt;
concretament, faràs:&lt;br /&gt;
*https://www.w3resource.com/javascript-exercises/javascript-conditional-statements-and-loops-exercises.php&lt;br /&gt;
&lt;br /&gt;
=Entrega=&lt;br /&gt;
Els alumnes entregaran al Schoology tots els fitxers generats (fitxers html). S'empaquetaran tots aquests fitxers i es pujaran al Moodle dins del termini d'entrega de la pràctica.&lt;br /&gt;
&lt;br /&gt;
Recorda la '''normativa''' per entregar les pràctiques al Google Classroom: [[ASIX-M10-UF2#Normativa_d.27entrega_de_les_pr.C3.A0ctiques_al_Google_Classroom]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Autor}}, setembre 2018&lt;br /&gt;
[[Categoria: Institut Jaume Balmes]]&lt;br /&gt;
[[Categoria: Assignatura DAW-M06-WEC]]&lt;/div&gt;</summary>
		<author><name>Joan</name></author>
		
	</entry>
</feed>