create account

My Coding Quiz #33 by eniolw

View this thread on: hive.blogpeakd.comecency.com
· @eniolw · (edited)
$15.82
My Coding Quiz #33
<div class="text-justify">

<center><h2>My Coding Quiz #33 👨‍💻🛠️🧩</h2></center>

<p>Welcome to the new installment of my series of <b>Coding Quizzes</b>, in which you will be able to test your knowledge and skills about programming and software development in a simple and fun way. If you want to learn more about it visit <a href="/@eniolw">my blog</a> here on Hive and the <a href="/@eniolw/my-coding-quiz-1">first post</a> where I introduced it.</p>

<h3>Without further ado, here's the riddle...</h3>

<br>
<center>
<img src="https://images.ecency.com/DQmctqHka1TBesSfQUJA6MdwAdqUDj9asTxwW7ogsWuLLTr/quiz_img_en.png" alt="Quiz">
<h6>By @eniolw</h6>
</center>

<br><center><h3>What's your choice?</h3></center>

<p><b>Solution to the <a href="/@eniolw/my-coding-quiz-32">previous quiz</a>:</b> <b>number</b>. Line 1 creates a string that can be easily interpreted as a date.</p> 

<p>Then we create three variables using the powerful <i>destructuring assignment</i> feature of JavaScript with which we assign to several variables the contents of an array or object, in this case the array created by the <code>split</code> method. The variables <code>m</code>, <code>d</code> and <code>y</code> have the values <b>'11'</b>, <b>'30'</b>, <b>'2023'</b> respectively.</p>

<p>We then initiate a series of nested <code>try-catch</code> clauses. One more level of nesting would make programmers like Linus Torvalds insult you, ha ha. Let's examine them more closely.</p>

<p><code>console.log(typeof Float(y))</code> cannot be executed because the <code>Float</code> function or class does not exist in JavaScript in this form. Did you know that?</p>

<p><code>console.log(typeof(+y))</code> does run because it is valid code. The parentheses for the <code>typeof</code> operator are unnecessary here, but they are not a syntax error. The key is that the <code>+</code> operator placed in front of a variable like this <i>will force or attempt a type conversion if the type of the variable is not numeric already</i>. As a consequence, the value of <code>y</code> will be converted to number type and we will get that as output.</p>

<p><code>console.log(typeof(y))</code> would not be able to be executed in this script, but it is valid code as well.</p>

<p>The crux of this quiz, therefore, is to know the potential of the <i>unary operator <code>+</code></i> to do these data type conversions. It is difficult to consider it a hack, since <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators">it is in fact the method recommended by MDN</a> and other specialized sites, which consider it the "fastest" and the "preferred" one, which in turn makes <code>ParseInt</code> and other similar conversion methods obsolete.</p>

<hr>

<p>If you want to blog about computer science and programming content, I invite you to join <a href="/">Hive</a> and participate in its communities, such as <a href="/created/hive-196387">STEM-social</a>, <a href="/created/hive-154226">Develop Spanish</a>, <a href="/created/hive-169321">Programming & Dev</a> and others.</p>

<hr>

<center><h2>Mi Quiz de Programación #33 👨‍💻🛠️🧩</h2></center>

<p>Bienvenido a mi nueva serie de <b>Quizzes de Programación</b>, en la cual podrás poner a prueba tus conocimientos y habilidades sobre programación y desarrollo de software de una manera sencilla y divertida.  Si quieres aprender más sobre ella visita <a href="/@eniolw">mi blog</a> aquí en Hive y el <a href="/@eniolw/my-coding-quiz-1">primer post</a> donde la presenté.</p>

<h3>Sin más preámbulos, he aquí el acertijo...</h3>

<br>
<center>
<img src="https://images.ecency.com/DQmfPmn1WRUieeFesM24vHVC6HnY9Q7soEi7EXvm3KFgV2Q/quiz_img_es.png" alt="Quiz">
<h6>Por @eniolw</h6>
</center>

<br><center><h3>¿Cuál es tu elección?</h3></center>

<p><b>Solución al <a href="/@eniolw/my-coding-quiz-32">quiz anterior</a>:</b> <b>number</b>. La línea 1 crea una cadena que puede interpretarse fácilmente como una fecha.</p>

<p>Luego creamos tres variables usando la potente funcionalidad de asignación <i>destructuring</i> de JavaScript con la que asignamos a varias variables el contenido de un array u objeto, en este caso el array creado por el <code>split</code> método. Las variables <code>m</code>, <code>d</code> y <code>y</code> tienen los valores <b>'11'</b>, <b>'30'</b>, <b>'2023'</b> respectivamente.</p>

<p>Luego iniciamos una serie de cláusulas <code>try-catch</code> anidadas. Un nivel más de anidamiento haría que programadores como Linus Torvalds te insultaran, ja, ja. Examinémoslos más de cerca.</p>

<p><code>console.log(typeof Float(y))</code> no se puede ejecutar porque la función o clase <code>Float</code> no existe en JavaScript de esta manera. ¿Lo sabías?</p>

<p><code>console.log(typeof(+y))</code> se ejecuta porque es un código válido. Los paréntesis para el operador <code>typeof</code> son innecesarios aquí, pero no constituyen un error de sintaxis. La clave es que el operador <code>+</code> colocado delante de una variable así <i>forzará o intentará una conversión de tipo si el tipo de la variable aún no es numérico</i>. Como consecuencia, el valor de <code>y</code> se convertirá a un tipo numérico y lo obtendremos como resultado.</p>

<p><code>console.log(typeof(y))</code> no podría ejecutarse en este script, pero también es un código válido.</p>

<p>El meollo de este quiz, por lo tanto, es conocer el potencial del <i>operador unario <code>+</code></i> para realizar estas conversiones de tipos de datos. Es difícil considerarlo un hack, ya que <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators">es en realidad el método recomendado por MDN</a> y otros sitios especializados, que lo consideran el "más rápido" y el "preferido", lo que a su vez hace que <code>ParseInt</code> y otros métodos de conversión similares queden obsoletos.</p>

<hr>

<p>Si quieres bloguear sobre contenido informático y de programación, te invito a unirte a <a href="/">Hive</a> y participar en sus comunidades, tales como <a href="/created/hive-196387">STEM-social</a>, <a href="/created/hive-154226">Develop Spanish</a>, <a href="/created/hive-169321">Programming & Dev</a> y otras.</p>

</div>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 573 others
properties (23)
authoreniolw
permlinkmy-coding-quiz-33
categoryhive-150329
json_metadata"{"image":["https://images.ecency.com/DQmctqHka1TBesSfQUJA6MdwAdqUDj9asTxwW7ogsWuLLTr/quiz_img_en.png","https://images.ecency.com/DQmfPmn1WRUieeFesM24vHVC6HnY9Q7soEi7EXvm3KFgV2Q/quiz_img_es.png"],"tags":["hive-150329","programming","coding","python","quiz","neoxian","proofofbrain","creativecoin","waivio","spanish"],"description":"My Coding Quiz #33 Welcome to the new installment of my series of Coding Quizzes, in which you will be able to test your knowledge and skills about programming and software development in a fun way.","app":"ecency/3.0.37-vision","format":"markdown+html","image_ratios":["0.8282","0.8282"]}"
created2023-11-16 01:33:21
last_update2023-11-18 18:37:15
depth0
children6
last_payout2023-11-23 01:33:21
cashout_time1969-12-31 23:59:59
total_payout_value7.968 HBD
curator_payout_value7.851 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length6,207
author_reputation253,328,400,128,603
root_title"My Coding Quiz #33"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id128,899,843
net_rshares33,744,063,725,236
author_curate_reward""
vote details (637)
@esalcedo ·
@tipu curate 8 
properties (22)
authoresalcedo
permlinkre-eniolw-s48fuy
categoryhive-150329
json_metadata{"tags":["hive-150329"],"app":"peakd/2023.10.1"}
created2023-11-16 20:06:36
last_update2023-11-16 20:06:36
depth1
children1
last_payout2023-11-23 20:06:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length15
author_reputation114,851,708,218,153
root_title"My Coding Quiz #33"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id128,921,115
net_rshares0
@tipu ·
<a href="https://tipu.online/hive_curator?esalcedo" target="_blank">Upvoted  &#128076;</a> (Mana: 0/72) <a href="https://peakd.com/hive/@reward.app/reward-app-quick-guide-updated" target="_blank">Liquid rewards</a>.
properties (22)
authortipu
permlinkre-re-eniolw-s48fuy-20231116t200642z
categoryhive-150329
json_metadata"{"app": "beem/0.24.26"}"
created2023-11-16 20:06:42
last_update2023-11-16 20:06:42
depth2
children0
last_payout2023-11-23 20:06:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length215
author_reputation55,902,105,514,997
root_title"My Coding Quiz #33"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id128,921,117
net_rshares0
@ganjafarmer ·
Oh wow this is pretty crazy! Absolute wild and crazy as well..

However I am actually very impressed. And I think that coding as well as coding boot camps and teaching other people this arcane mysterious art would be more prevalent here on the blockchain...

I do a secrets of Hive class and I'd totally trade you for some beginning coding knowledge. I think that your coding content actually I might be more important than you understand..

Nobody here really explains it. We've got a lot of really great coders here that talk in Klingon! 

Thank you very much for your excellent post. As well as thank you for sharing the knowledge of coding.

#freecompliments
properties (22)
authorganjafarmer
permlinkre-eniolw-20231116t04827892z
categoryhive-150329
json_metadata{"type":"comment","tags":["hive-150329","programming","coding","python","quiz","neoxian","proofofbrain","creativecoin","waivio","spanish"],"app":"ecency/3.0.44-mobile","format":"markdown+html"}
created2023-11-16 08:48:30
last_update2023-11-16 08:48:30
depth1
children2
last_payout2023-11-23 08:48:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length662
author_reputation672,900,775,922,025
root_title"My Coding Quiz #33"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id128,906,316
net_rshares0
@eniolw ·
Thanks, I'm glad you find this instructive.
properties (22)
authoreniolw
permlinkre-ganjafarmer-20231118t12815380z
categoryhive-150329
json_metadata{"tags":["hive-150329","programming","coding","python","quiz","neoxian","proofofbrain","creativecoin","waivio","spanish"],"app":"ecency/3.0.37-vision","format":"markdown+html"}
created2023-11-18 16:08:27
last_update2023-11-18 16:08:27
depth2
children1
last_payout2023-11-25 16:08:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length43
author_reputation253,328,400,128,603
root_title"My Coding Quiz #33"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id128,971,442
net_rshares0
@ganjafarmer ·
You are very welcome. 
properties (22)
authorganjafarmer
permlinkre-eniolw-20231118t81351300z
categoryhive-150329
json_metadata{"type":"comment","tags":["hive-150329","programming","coding","python","quiz","neoxian","proofofbrain","creativecoin","waivio","spanish"],"app":"ecency/3.0.44-mobile","format":"markdown+html"}
created2023-11-18 16:13:51
last_update2023-11-18 16:13:51
depth3
children0
last_payout2023-11-25 16:13:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length22
author_reputation672,900,775,922,025
root_title"My Coding Quiz #33"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id128,971,626
net_rshares0
@stemsocial ·
re-eniolw-my-coding-quiz-33-20231116t233702820z
<div class='text-justify'> <div class='pull-left'>
 <img src='https://stem.openhive.network/images/stemsocialsupport7.png'> </div>

Thanks for your contribution to the <a href='/trending/hive-196387'>STEMsocial community</a>. Feel free to join us on <a href='https://discord.gg/9c7pKVD'>discord</a> to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support.&nbsp;<br />&nbsp;<br />
</div>
properties (22)
authorstemsocial
permlinkre-eniolw-my-coding-quiz-33-20231116t233702820z
categoryhive-150329
json_metadata{"app":"STEMsocial"}
created2023-11-16 23:37:03
last_update2023-11-16 23:37:03
depth1
children0
last_payout2023-11-23 23:37:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length565
author_reputation22,903,676,462,363
root_title"My Coding Quiz #33"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id128,924,645
net_rshares0