<?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._Exercicis_de_consola</id>
	<title>Sintaxi del llenguatge. Exercicis de consola - 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._Exercicis_de_consola"/>
	<link rel="alternate" type="text/html" href="http://wiki.joanillo.org/index.php?title=Sintaxi_del_llenguatge._Exercicis_de_consola&amp;action=history"/>
	<updated>2026-08-30T17:28:01Z</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._Exercicis_de_consola&amp;diff=297049&amp;oldid=prev</id>
		<title>Joan a 15:21, 30 oct 2020</title>
		<link rel="alternate" type="text/html" href="http://wiki.joanillo.org/index.php?title=Sintaxi_del_llenguatge._Exercicis_de_consola&amp;diff=297049&amp;oldid=prev"/>
		<updated>2020-10-30T15:21:31Z</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 15:21, 30 oct 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-l48&quot; &gt;Línia 48:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Línia 48:&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;&amp;lt;pre&amp;gt;&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;&amp;lt;pre&amp;gt;&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;$ node ordinadorObj.js &amp;gt; sortida.txt&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;$ node ordinadorObj.js &amp;gt; sortida.txt&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;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;&amp;lt;/pre&amp;gt;&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;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;&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;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;'''Demanar dades en línia de comandes'''. És possible fer-ho amb NodeJS?:&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;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;*https://stackoverflow.com/questions/8128578/reading-value-from-console-interactively&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;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;Provar el següent codi:&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;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;&amp;lt;pre&amp;gt;&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;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;const readline = require('readline');&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;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;&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;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;const rl = readline.createInterface({&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;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;  input: process.stdin,&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;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;  output: process.stdout&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;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;});&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;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;&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;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;rl.question('What do you think of Node.js? ', (answer) =&amp;gt; {&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;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;  console.log('Thank you for your valuable feedback:', answer);&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;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;  rl.close();&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;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;});&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;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;&amp;lt;/pre&amp;gt;&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;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;&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;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;&amp;lt;pre&amp;gt;&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;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;const readline = require('readline');&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;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;&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;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;const rl = readline.createInterface({&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;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;  input: process.stdin,&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;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;  output: process.stdout&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;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;});&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;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;&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;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;rl.question('Quina hora és? (0-24): ', (hora) =&amp;gt; {&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;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;  console.log('La teva hora:', hora);&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;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;  rl.close();&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;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;if (hora &amp;lt; 14)&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;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;{&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;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;   console.log(&amp;quot;Bon dia&amp;quot;);&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;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;} else if(hora &amp;lt; 20) {&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;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;   console.log(&amp;quot;Bona tarda&amp;quot;);&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;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;} else {&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;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;   console.log(&amp;quot;Bona nit&amp;quot;);&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;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;}&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;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;});&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;&amp;lt;/pre&amp;gt;&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;&amp;lt;/pre&amp;gt;&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;/table&gt;</summary>
		<author><name>Joan</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.joanillo.org/index.php?title=Sintaxi_del_llenguatge._Exercicis_de_consola&amp;diff=258562&amp;oldid=prev</id>
		<title>Joan: /* Bateria d'exercicis */</title>
		<link rel="alternate" type="text/html" href="http://wiki.joanillo.org/index.php?title=Sintaxi_del_llenguatge._Exercicis_de_consola&amp;diff=258562&amp;oldid=prev"/>
		<updated>2019-10-28T19:45:01Z</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&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;
En la primera pràctica vas instal.lar el ''SpiderMonkey'' i el vas començar a fer servir, però no li vam treure el suc. Ara que ja ens hem iniciat en la sintaxi de Javascript podràs practicar directament amb exemples purs javascript, amb l'intèrpret de comandes la consola, sense la necessitat d'integrar el codi dins una pàgina html.&lt;br /&gt;
&lt;br /&gt;
En aquesta pràctica consolidarem la sintaxi fent servir els conceptes que has estudiat: declaració de variables, operacions aritmètiques i lògiques, bucles, condicionals, objectes,...&lt;br /&gt;
&lt;br /&gt;
=Referències=&lt;br /&gt;
&lt;br /&gt;
=Desenvolupament=&lt;br /&gt;
En la teoria de sintaxi de Javascript vam veure com es creava un objecte utilitzant el constructor, i es definien unes propietats i uns mètodes. Un exemple de fitxer javascript pur que ho fa es presenta a continuació. Recorda que ara no podem utilitzar ''document.write'', perquè l'objecte ''document'' representa la pàgina activa del teu navegador web, i ara no estem treballant en aquest context. Per contra, per mostrar informació per la consola podem utilitzar ''print''.&lt;br /&gt;
&lt;br /&gt;
fitxer '''ordinadorObj.js''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//definir l'objecte ordinador, amb diferents propietats, i el mètode canviarEstat&lt;br /&gt;
//que permet encendre i apagar l'ordinador.&lt;br /&gt;
&lt;br /&gt;
function ordinadorObj(marca,cpu,ram,hdd) {&lt;br /&gt;
	this.marca=marca&lt;br /&gt;
	this.cpu=cpu;&lt;br /&gt;
	this.ram=ram;&lt;br /&gt;
	this.hdd=hdd;&lt;br /&gt;
	//en l'estat inicial està apagat&lt;br /&gt;
	this.estat=0;&lt;br /&gt;
&lt;br /&gt;
	this.canviarEstat=canviarEstat;&lt;br /&gt;
	function canviarEstat(valor) {&lt;br /&gt;
		this.estat=valor;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
myOrdinador=new ordinadorObj(&amp;quot;DELL&amp;quot;,&amp;quot;Core i5&amp;quot;,4,&amp;quot;500GB&amp;quot;);&lt;br /&gt;
console.log(myOrdinador.cpu);&lt;br /&gt;
console.log(myOrdinador.estat);&lt;br /&gt;
//encenem&lt;br /&gt;
myOrdinador.canviarEstat(1);&lt;br /&gt;
console.log(myOrdinador.estat);&lt;br /&gt;
//apaguem&lt;br /&gt;
myOrdinador.canviarEstat(0);&lt;br /&gt;
console.log(myOrdinador.estat);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Per executar-lo:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ node ordinadorObj.js&lt;br /&gt;
Core i5&lt;br /&gt;
1&lt;br /&gt;
0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Pots redirigir la sortida per pantalla a un fitxer:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ node ordinadorObj.js &amp;gt; sortida.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Demanar dades en línia de comandes'''. És possible fer-ho amb NodeJS?:&lt;br /&gt;
*https://stackoverflow.com/questions/8128578/reading-value-from-console-interactively&lt;br /&gt;
Provar el següent codi:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
const readline = require('readline');&lt;br /&gt;
&lt;br /&gt;
const rl = readline.createInterface({&lt;br /&gt;
  input: process.stdin,&lt;br /&gt;
  output: process.stdout&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
rl.question('What do you think of Node.js? ', (answer) =&amp;gt; {&lt;br /&gt;
  console.log('Thank you for your valuable feedback:', answer);&lt;br /&gt;
  rl.close();&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
const readline = require('readline');&lt;br /&gt;
&lt;br /&gt;
const rl = readline.createInterface({&lt;br /&gt;
  input: process.stdin,&lt;br /&gt;
  output: process.stdout&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
rl.question('Quina hora és? (0-24): ', (hora) =&amp;gt; {&lt;br /&gt;
  console.log('La teva hora:', hora);&lt;br /&gt;
  rl.close();&lt;br /&gt;
if (hora &amp;lt; 14)&lt;br /&gt;
{&lt;br /&gt;
   console.log(&amp;quot;Bon dia&amp;quot;);&lt;br /&gt;
} else if(hora &amp;lt; 20) {&lt;br /&gt;
   console.log(&amp;quot;Bona tarda&amp;quot;);&lt;br /&gt;
} else {&lt;br /&gt;
   console.log(&amp;quot;Bona nit&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Bateria d'exercicis==&lt;br /&gt;
'''1.''' Fer un exercici (''strings.js'') on defineixes unes variables com a objecte String. Avalua les següents funcions (http://www.w3schools.com/jsref/jsref_obj_string.asp):&lt;br /&gt;
*charAt()&lt;br /&gt;
*concat()&lt;br /&gt;
*indexOf()&lt;br /&gt;
*match()&lt;br /&gt;
*replace()&lt;br /&gt;
*substring&lt;br /&gt;
*search()&lt;br /&gt;
*split()&lt;br /&gt;
*substr()&lt;br /&gt;
*valueOf()&lt;br /&gt;
&lt;br /&gt;
'''2a.''' Escriu les taules de multiplicar del 1 al 10 (bucles).&lt;br /&gt;
&lt;br /&gt;
'''2b.''' Entra un número del 1 al 10, i escriu la taula de multiplicar d'aquest número (bucle).&lt;br /&gt;
&lt;br /&gt;
'''3.''' Avarigua el mes de l'any en què estem, i digues en quina estació de l'any estem. Utilitza ''if'', i també ''switch''.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var day=new Date().getDay();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''4.''' Crear un Array d'assignatures (buit). Fes un bucle i demana 10 vegades el nom d'una assignatura. Has d'anar omplint l'array. Finalment, fes un bucle i printa totes les assignatures.&lt;br /&gt;
&lt;br /&gt;
'''5'''.comprovar https://www.w3schools.com/js/js_booleans.asp. Es dóna la solució amb el fitxer '''boolean.js''': &lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
//comprovar http://www.w3schools.com/js/js_obj_boolean.asp&lt;br /&gt;
//The Boolean object represents two values: &amp;quot;true&amp;quot; or &amp;quot;false&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
//The following code creates a Boolean object called myBoolean:&lt;br /&gt;
//var myBoolean=new Boolean();&lt;br /&gt;
&lt;br /&gt;
//If the Boolean object has no initial value, or if the passed value is one of the following:&lt;br /&gt;
&lt;br /&gt;
//    0&lt;br /&gt;
//    -0&lt;br /&gt;
//    null&lt;br /&gt;
//    &amp;quot;&amp;quot;&lt;br /&gt;
//    false&lt;br /&gt;
//    undefined&lt;br /&gt;
//    NaN&lt;br /&gt;
&lt;br /&gt;
//the object is set to false. For any other value it is set to true (even with the string &amp;quot;false&amp;quot;)!&lt;br /&gt;
//NOTA! Aquesta última afirmació no és correcta del tot. Comprovació...&lt;br /&gt;
&lt;br /&gt;
var myBoolean1=new Boolean();&lt;br /&gt;
var myBoolean2=new Boolean();&lt;br /&gt;
var myBoolean3=new Boolean();&lt;br /&gt;
var myBoolean4=new Boolean();&lt;br /&gt;
var myBoolean5=new Boolean();&lt;br /&gt;
var myBoolean6=new Boolean();&lt;br /&gt;
var myBoolean7=new Boolean();&lt;br /&gt;
var myBoolean8=new Boolean();&lt;br /&gt;
var myBoolean9=new Boolean();&lt;br /&gt;
&lt;br /&gt;
myBoolean1=0;&lt;br /&gt;
myBoolean2=-0;&lt;br /&gt;
myBoolean3=null;&lt;br /&gt;
myBoolean4=&amp;quot;&amp;quot;;&lt;br /&gt;
myBoolean5=false;&lt;br /&gt;
myBoolean6=undefined;&lt;br /&gt;
myBoolean7=NaN;&lt;br /&gt;
myBoolean8=1;&lt;br /&gt;
myBoolean9=&amp;quot;false&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
console.log(myBoolean1);&lt;br /&gt;
console.log(myBoolean2);&lt;br /&gt;
console.log(myBoolean3);&lt;br /&gt;
console.log(myBoolean4);&lt;br /&gt;
console.log(myBoolean5);&lt;br /&gt;
console.log(myBoolean6);&lt;br /&gt;
console.log(myBoolean7);&lt;br /&gt;
console.log(myBoolean8);&lt;br /&gt;
console.log(myBoolean9);&lt;br /&gt;
&lt;br /&gt;
if (myBoolean1==false) { console.log(&amp;quot;és fals&amp;quot;) } else { console.log(&amp;quot;és vertader&amp;quot;) };&lt;br /&gt;
if (myBoolean2==false) { console.log(&amp;quot;és fals&amp;quot;) } else { console.log(&amp;quot;és vertader&amp;quot;) };&lt;br /&gt;
if (myBoolean3==false) { console.log(&amp;quot;és fals&amp;quot;) } else { console.log(&amp;quot;és vertader&amp;quot;) };&lt;br /&gt;
if (myBoolean4==false) { console.log(&amp;quot;és fals&amp;quot;) } else { console.log(&amp;quot;és vertader&amp;quot;) };&lt;br /&gt;
if (myBoolean5==false) { console.log(&amp;quot;és fals&amp;quot;) } else { console.log(&amp;quot;és vertader&amp;quot;) };&lt;br /&gt;
if (myBoolean6==false) { console.log(&amp;quot;és fals&amp;quot;) } else { console.log(&amp;quot;és vertader&amp;quot;) };&lt;br /&gt;
if (myBoolean7==false) { console.log(&amp;quot;és fals&amp;quot;) } else { console.log(&amp;quot;és vertader&amp;quot;) };&lt;br /&gt;
if (myBoolean8==false) { console.log(&amp;quot;és fals&amp;quot;) } else { console.log(&amp;quot;és vertader&amp;quot;) };&lt;br /&gt;
if (myBoolean9==false) { console.log(&amp;quot;és fals&amp;quot;) } else { console.log(&amp;quot;és vertader&amp;quot;) };&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''6.''' Generar 100 números aleatoris del 1 al 100 (fés un bucle), i trobar la mitjana aritmètica de tots aquests números. Dóna la solució amb dos números decimals.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!doctype html&amp;gt;&lt;br /&gt;
&amp;lt;html lang=&amp;quot;en&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;meta charset=&amp;quot;UTF-8&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;Mitjana números aleatoris&amp;lt;/title&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;h1&amp;gt;Mitjana números aleatoris&amp;lt;/h1&amp;gt;&lt;br /&gt;
    &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
	var num, suma, mitjana;&lt;br /&gt;
	suma = 0; //important!!!&lt;br /&gt;
	for (var i=0;i&amp;lt;100;i++) {&lt;br /&gt;
		//http://www.w3schools.com/jsref/jsref_random.asp&lt;br /&gt;
		num = Math.random()*100; &lt;br /&gt;
		suma += num;&lt;br /&gt;
		console.log(num + &amp;quot; &amp;quot; + suma);&lt;br /&gt;
	}&lt;br /&gt;
	mitjana = suma / 100;&lt;br /&gt;
	console.log(&amp;quot;Mitjana: &amp;quot; + mitjana.toFixed(2));&lt;br /&gt;
	document.write (&amp;quot;La mitjana és: &amp;quot; + mitjana.toFixed(2));&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''7.''' Entra un número pel teclat (o bé com a argument en la línia de comandes). Comprova que és un número. Què passa si li sumes 1? És necessària la funció de parsejar a enter? Se't dóna la solució (però millor si ho intentes fer pel teu compte abans de mirar la solució.&lt;br /&gt;
&lt;br /&gt;
'''parseint.js'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var args = process.argv;&lt;br /&gt;
console.log(args[2]);&lt;br /&gt;
num = args[2];&lt;br /&gt;
&lt;br /&gt;
if (isNaN(num)) {&lt;br /&gt;
	console.log(&amp;quot;No és un número&amp;quot;);&lt;br /&gt;
} else {&lt;br /&gt;
	console.log(num+1);&lt;br /&gt;
	num=parseInt(num);&lt;br /&gt;
	console.log(num+1);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
En la línia de comandes:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ nodejs parseint.js 4&lt;br /&gt;
4&lt;br /&gt;
41&lt;br /&gt;
5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''8. '''. De l'objecte ''Date'', repassa els mètodes ''toLocaleDateString()'', ''toLocaleTimeString()'' i ''toLocaleString()''. Aquesta és la manera més senzilla d'obtenir la data i hora del sistema amb el format que utilitzem normalment. Utilitzant alguna d'aquestes funcions, obté la data del sistema amb el format:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dd-mm-yyyy a les hh::mi::ss&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Utilitzant ''prototype'', crea el mètode ''el_meu_format()'' que respongui al format anterior.&lt;br /&gt;
&lt;br /&gt;
'''9.''' Estem organitzant un MOOC (''Massive Online Open Course''), i volem que el ''deadline'' de l'examen final comenci a les 15h del 19/11/2018 (hora local d'aquí). Quina hora UTC haurem d'anunciar als participants? Per a una persona que visqui a Kashgar (Xingjian), quina serà la seva hora local?&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var d1 = new Date(2018, 10, 19, 15, 0,0,0);&lt;br /&gt;
var d2 = new Date(2018, 10, 19, 15+7, 0,0,0); &lt;br /&gt;
//hem de sumar 7 hores respecte la local,&lt;br /&gt;
// i hem de sumar 8 hores respecte la UTC&lt;br /&gt;
&lt;br /&gt;
//GMT (o UTC) + 8&lt;br /&gt;
&lt;br /&gt;
console.log(d1.toUTCString());&lt;br /&gt;
&lt;br /&gt;
console.log(d1.toLocaleDateString());&lt;br /&gt;
console.log(d1.toLocaleString());&lt;br /&gt;
&lt;br /&gt;
toLocaleString()	Converts a Date object to a string, using locale conventions&lt;br /&gt;
&lt;br /&gt;
console.log(d2.toLocaleString());&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Una altra solució:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var data=new Date(2018,10,19,15,00,00);&lt;br /&gt;
var data2=new Date(data);&lt;br /&gt;
data2.setHours(data2.getHours()+7);&lt;br /&gt;
console.log(&amp;quot;Hora local:\t&amp;quot; + data.toLocaleString());&lt;br /&gt;
console.log(&amp;quot;Hora UTC:\t&amp;quot; + data.toUTCString());&lt;br /&gt;
console.log(&amp;quot;Hora Kashgar:\t&amp;quot; + data2.toLocaleString());&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''10.''' Una regla bàsica quan redactem un text: ''Després de punt hi ha un espai...''. A continuació tenim un text on l'escriptor s'ha fet un lio i trobem diferents casos. Posar ordre, i fer que després de punt tinguem un sol espai en blanc. Evidentment, ho farem amb expressions regulars, i el mètode ''replace()'' dels String.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
A slowly widening smile appeared on Powells face. Donovan continued, And think of that screwballs face when he sees us do it?. Robots are, of course, manufactured on Earth, but their shipment through apace is much simpler if it can be done in parts to be put together at their place of use.  It also, incidentally, eliminates the possibility of robots, in complete adjustment, wandering off while still on Earth and thus bringing U. S. Robots face to face with the strict laws against robots on Earth.Still, it placed upon men such as Powell and Donovan the necessity of synthesis of complete robots, - a grievous and complicated task.     Powell and Donovan were never so aware of that fact as upon that particular day when, in the assembly room, they undertook to create a robot under the watchful eyes of QT 1, Prophet of the Master.The robot in question, a simple MC model, lay upon the table, almost complete. Three hours work left only the bead undone, and Powell paused to swab his forehead and glanced uncertainly at Cutie.The glance was not a reassuring one. For three hours, Cutie had sat, speechless and motionless, and his face, inexpressive at all times, was now absolutely unreadable. Powell groaned. Lets get the brain in now, Mike! 	Donovan uncapped the tightly sealed container and from the oil bath within he withdrew a second cube. Opening this in turn, he removed a globe from its sponge-rubber casing.He handled it gingerly, for it was the most complicated mechanism ever created by man.  Inside the thin platinumplated skin of the globe was a positronic brain, in whose delicately unstable structure were enforced calculated neuronic paths, which imbued each robot with what amounted to a pre-natal education.It fitted snugly into the cavity in the skull of the robot on the table. Blue metal closed over it and was welded tightly by the tiny atomic flare. Photoelectric eyes were attached carefully, screwed tightly into place and covered by thin, transparent sheets of steel-hard plastic.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
text extret de ''I, Robot'', de Isaac Asimov.&lt;br /&gt;
&lt;br /&gt;
'''solució''':&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var str = &amp;quot;A slowly widening ...&amp;quot;;&lt;br /&gt;
var patt = /\.\s*/g;&lt;br /&gt;
// o bé&lt;br /&gt;
//var patt = new RegExp(/\.\s*/, &amp;quot;g&amp;quot;); &lt;br /&gt;
&lt;br /&gt;
var str = str.replace(patt, &amp;quot;. &amp;quot;);&lt;br /&gt;
&lt;br /&gt;
$ node prova.js &amp;gt; output.txt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Entrega=&lt;br /&gt;
Fés la bateria d'exercicis que se't proposa i penja'ls al Schoology. Inclou també les proves i ampliacions que hagis fet.&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;
{{Autor}}, octubre 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>