JavaScript(ES2015ïŒES6ïŒ) ãProgateðJavaScript â €ïŒ2ç« ããã±ãŒãžã䜿ããïŒã
JavaScript â
€ã¯1ã€ã®èšé²ã«ãŸãšããããšæã£ãŠããã®ã§ãããååã1ïœ20ïœããã£ãŠãããã£ãŠããðð€ðãªç¶æ
ãéãªã£ãŠããããæè¿ç¹ã«ãŸãšãŸã£ãåŠç¿æéã確ä¿ã§ããªãããæ¯æ¥éšã ã⊠ãçµå±2åã«åããŸãããããŒããŒã®ãç°¡æœã«èšããšããããªæããããïŒã£ãŠã€ãã§ãâ
ð
âŠâŠ
åã«èšãèš³ã¶ã£ããããã£ãã ãã§ããããžããããªæããããã§ãïŒïŒè¶
éãçŽãâ
ïŒæ°ãåãçŽããŠïŒããªã ãã«ðâïžðïŒæåŸã®2矜ãçä»ããŸãÙ©( 'Ï' )Ùâª
ðããã±ãŒãžïŒ1ïŒ
ðããã±ãŒãžïŒ2ïŒ
ãðããã±ãŒãžã
ðžJavaScriptã®äžçã§ã¯ãä»è
ãäœã£ã䟿å©ãªããã°ã©ã ãããã±ãŒãžãšãã圢ã§å
¬éãããŠããã
ãâJavaScriptã®æ©èœã䜿ããšããã®ããã±ãŒãžãèªåã®ããã°ã©ã äžã«çµã¿èŸŒãã§äœ¿çšããããšãå¯èœãšãªããïŒProgateæ§ããïŒ
ðžããã±ãŒãžã®import
ãâ import å®æ°å from "ããã±ãŒãžå " ;
ãâð¥ãchalkãããã±ãŒãžð¥ã§æåè²ã®å€æŽãå¯èœ
ðžã³ã³ãœãŒã«ããå€ãåãåã
ãâããã±ãŒãžãäœã
ãâå
¥åãããå€ã«å¿ããŠãã€ã³ã¹ã¿ã³ã¹ãäœæã
ð¥ãreadline-syncãããã±ãŒãžð¥ã§ã
console.logãžã®å€ã®å
¥åãšããã®å
¥åå€ãããã°ã©ã å
ã§äœ¿çšããããšãå¯èœãšãªãã
ãâ質åæã®åºåïŒreadlineSync.question(質åæ) ;
ãâå
¥åãããå€ã¯ãå®æ°ãå€æ°ãžã®ä»£å
¥ãå¯èœã
ãâ質åæãåºåããããšãåŠçãæ¢ãŸãã
ãâconsole.logå€ã«å ¥åããããšã次ã®åŠçã«é²ãã
â ïžreadlineSync.question(質åæ) ;
ãreadlineSync.questionInt(æŽæ°) ;
ã€ãã€âŠ
ãªãããäžæè°ã®åœã«èœã¡ãŠããæèŠâŠðâ°âïžðºâ ïžâ¥ïžðžâŠïžâ£ïžèœã¡ãããšãªããã©âŠ
ããã±ãŒãžã®ãªããšãªãæå端ãªãð±ðŠ
äžå¿ããªããåãããšãåºæ¥ããã©ãã¹ãŒããŒãµã€ã€äºº4ã«ãªã£ãæ空ã«å©ããŠããã£ãããŒã¢ã«ã®æ°åâŠ
ããŸãšãã
ååãäœè£ã¶ã£ãããŠãã®ç« ã«å
¥ããªããŠè¯ãã£ããåŠãæ¬åœã«è¯ãã£ã⊠æ¹ããŠãã®èšé²ãèŠãŠã¿ãŠããððððŠããªæããçµå±1ïœ30ïœãåŠããã以äžããã£ãæ°ãããâŠïŒçŽ°ã
åãçµãã§ãã®ã§ïŒã
å
·äœçãªäœ¿çšã€ã¡ãŒãžãæ§ç¯ã§ããªãããšãšãèªåã§ã§ããèªä¿¡ããªãããšã§ãå®å
šã«äžæè°ã®åœã«èœã¡ããŠãŒãã³ç¶æ
ã§ãðœðŠæ空ã®å©ãããªãäžãäžæè°ã®åœã®å€äººãã¡ãšã¯âŠã圌ã¯æŠããªãã§ãããæŠããªãã§ãã圌ãªããã£ãšãå€äººã®ãµãããŠãã®å Žã«éŠŽæãããšåªåããããºã§ãïŒããšãæ¶ããæ¥ããã£ããšããŠã⊠ãããããã¿ããã§ãâšããããªãã¿ããã«ãç§ã¯ãªãããâŠâŠã
åãããªãããäžå®ã§ãã³ã·ã§ã³ããããããªã£ãŠããã®ã§ããšããããã次ã«é²ã¿ãŸãâŠðœðœðœâš
ãã®èšäºãæ°ã«å ¥ã£ãããµããŒããããŠã¿ãŸãããïŒ