JavaScript ãðPaizaâ ïŒJavaScriptãã¯ããããïŒã
ãã®åã®è¯ããšããã¯ã
ãåŠç¿ç®çãããèšèªéçºã®èæ¯ããã䜿çšãããŠããå®äŸãçããµãŸããªããããã身è¿ã«ã€ã¡ãŒãžããããåŠç¿ç°å¢ãæäŸããŠãã ããç¹ã§ããð¥°
ããã®å¥³åãéçºè
ããã«ä»£ãã£ãŠãåããããã芪åã«æ瀺ããŠãã ãããŸãðãç²ããããç¡çããã¡ãã£ãšäŒæ©ããŠãã ãããããšãèšãããã®ããåãã£ãã¿ãŒã«ãã£ãŠãäžèšã³ã¡ã³ããå€ãã£ãŠãããããŠããããã¡ãã¡åªãã⊠å¯æãããªãã®ãð
ãééãããããã€ã³ãããè£è¶³äºé
ããäºåç¥èãçã®å°ãã¿æ
å ±ããããããããåç»å
ã§ããšã©ãŒäŸãã瀺ããéãæ£è§£ããéã®å¹æé³ããã¡ãã¡é¢çœãâŠïŒç§ã«ã¯â
ïŒååã¯åçŽäœæ¥ã£ãœãã®ãç¶ããŸãããã¡ãããšãæŒç¿èª²é¡ããçšæãããŠããã®ãé
åã§ãâïžãŸããäžèŠç¡é§ã«èŠããæŠåšïŒæ¹æ³ïŒããå®æŠã§ã®äŸããããŠãããããæã«äŸ¿å©ã ãã䜿ããã ããããšæããŠããããšããã芪åâŠâšããäžã€ã®è¯ãæã¯ãããã°ã©ãã³ã°çšèªãäžåäžåæå衚瀺ã§æããŠãããŸããã¡ãããšèŠããŠãããã¯èªä¿¡ãªãã§ããð
ãããµãŒãããšããæãããè¯ãæãã§ãâ
#3ã«ããããã£ããšãã㧠ããç¡æäŒå¡ç»é²ããé²ããããŸãããçŸç¶ç¢ºèªã¢ã³ã±ãŒããããã2ã3åã§ç»é²å®äºãã¡ãªã¿ã«ãä»ã®ç§ã®ã¹ããŒã¿ã¹ã¯ãæ人ãã
ãæåã«ã
// ããŒã®å
¥ååŸ
ã¡ç¶æ
ã«ããã
ãµãŒããŒçã®ã³ã³ãã¥ãŒã¿ãŒå
ã®ããã°ã©ã ãšããŠåããNode.jsã®ãããªããã°ã©ã ã«å¯ŸããŠãåŒã³åºãéã«ããŒã¿ãæž¡ãæ¹æ³ã®äžã€ïŒæšæºå
¥åïŒ
stdinãïŒãstandardïŒæšæºïŒinputïŒå
¥åïŒ
ãïŒ04:HTMLã衚瀺ããŠã¿ããã
ðžJavaScriptã®ããã°ã©ã ã§æ¹è¡ããªãå Žå
ãâprocess.stdout.writeïŒã¹ã¿ã³ããŒãã¢ãŠã ã©ã€ãïŒ
ãâã\nã
ãïŒ05:å€æ°ã䜿ããããã«ãªãã ã
ðž- JavaScriptã®äºçŽèª(ããŒã¯ãŒã)
https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Reserved_Words
ðžvar player = "åè
"; // æååããŒã¿ã®å€æ°
ã var number = 3; // æŽæ°ããŒã¿ã®å€æ°
ãïŒ06:ãµã€ã³ããäœããã
ðé¢æ°ã®äŸïŒ
ãconsole.log("hello world") ïŒæå®ããæååãåºåããã
ãMath.random() ïŒ0以äž1æªæºã®ã©ã³ãã ãªæ°å€ãåºåããã
ãâé¢æ°ã®æ»ãå€(ãã©ãã¡)ãšã¯ãé¢æ°ã®åŠççµæã®ããŒã¿ã®ããšã§ããè¿ãå€ãšåŒã¶å ŽåããããŸãã
ããMath.random()ãšããé¢æ°ãåŒã³åºããšãã©ã³ãã ãªæ°å€ãæ»ãå€ãšãªããŸãã
ðžparseInt( Math.random( )*10 ) + 1 ;
ãâã©ã³ãã é¢æ°å€ã®å°æ°ç¹ä»¥äžãåãäžããã0ãã代å
¥ãããéã®ã0衚瀺ããé²ãããã®ïŒ1ã
ããparseIntãâãæŽæ°å°çš
ããããããããïŒåŒæ°ã解æããããšã§æŽæ°ãåŸãããšãã§ãããªããžã§ã¯ãïŒ
ããparse Floatãâãå°æ°ç¹ãã
ãïŒ07:æŒç®åã§èšç®ããŠã¿ããã
ðžèšç®ã®åªå
é äœ
ãé«ã ( )ãïŒã * / %ãïŒãäœã + -
ãïŒ08:å€æ®µãèšç®ããŠã¿ããã
ðžæŒç®åãšrandomé¢æ°ã䜿ã£ãŠããªã³ãŽã®å€æ®µãèšç®ããããªã³ã©ã€ã³ã·ã§ããã³ã°ãµã€ãã®ãããªç°¡åãªããã°ã©ã ãäœæããŸãã
ãvar number = parseInt(Math.random() * 10) + 1;// å¹æ° 1 ïœ 10
ãconsole.log("äœé100ããã®ã¹ã©ã€ã ã" + number + "å¹ãããããã");
ãïŒ09:ããŒã¿ã®åãèŠãããã
JavaScriptã§ã¯ãããŒã¿ãšæååãå³å¯ã«åããŠãã
倧ããããšããšããã®ã«ãå±åŒ·ãªæŠå£«ã«ãªããã£ãâŠ
ããå¯æãããªãã®âŠð
ããŸãšãã
ãåºæ¬çã«ã¯æºè¶³ã®ããåŠç¿å
容ã§ãããããã¯ãããã¯ãProgateæ§ãã£ãŠã®ããšã ãšæããŸãããProgateæ§ã§åŠç¿é
ç®ã®åŸ©ç¿åæ°ãèšé²ããããã1ããããçŽãïŒãããšãã³ãŒãã®ç¢ºèªã ãã«ããïŒãšéžã¹ãæ©èœããããããã£ããã ãªããšæããŸããã
ããã ãProgateæ§ã ãã§ã¯ç¥ããªãã£ãããšãããã®ã§ãdotinstallãããšåæ§ã«ãPaizaãããšã仲è¯ãããŠãããããšæããŸãããŸããåæ¹ã®ææã³ãŒã¹ãæ°ã«ãªããšããã§ãããçæéäžéå端ã«ãªããããªã®ã§ãå
ãã¯ãåºæ¥ããšããããâïž
ãPaizaããã®ç¡æã³ãŒã¹ãå¶èŠãããã次ã«ç§»ããŸãÙ©( 'Ï' )Ù
ãã®èšäºãæ°ã«å ¥ã£ãããµããŒããããŠã¿ãŸãããïŒ