JavaScript(ES2015ïŒES6ïŒ) ãProgateð£ð£JavaScript IIãïŒ1ç« ç¹°ãè¿ãåŠçïŒã
JavaScript IIã§ã¯ãåããããªåŠçãäœåºŠãç¹°ãè¿ãã®ã«äŸ¿å©ãªãç¹°ãè¿ãåŠçãããé
åããããªããžã§ã¯ããã®åºæ¬çãªäœ¿ãæ¹ã«ã€ããŠåŠç¿ããŸãïŒå
š5ç« ïŒãç®æšã¯2ïœã
ð£å€æ°ã®åŸ©ç¿
ð£whileæ
ð£foræ
ð£ç¹°ãè¿ãåŠçã®ãŸãšã
ãð£å€æ°ã®åŸ©ç¿ã
ðæ©éå¿ããŠãð±âââ
ã// å€æ°numberãå®çŸ©ããŠãã ãã
let number=0;
// å€æ°numberã«1ãå ããŠããã®åŸã«å€æ°numberã®å€ãåºåããŠãã ãã
number=number+1;ãâãæåŸã®ãïŒãæ§(ToT)
console.log(number);
ðžç¹°ãè¿ãåŠçã®whileæ
ãããŸãæ¡ä»¶åŒã®å€å®ãè¡ãããtrueã®æã®ã¿{}ã®äžã§åŠçã1床å®è¡ãããŸãããã®åŸãåã³æ¡ä»¶åŒãtrueãã©ãããã§ãã¯ãããtrueã§ããã°ããäžåºŠåŠçãå®è¡ãããŸããïŒProgateæ§ããïŒãâãã£ããèšã£ãŠããã©ããããããšã§ãããâŠ(°_°)ïŒïŒ
â ïžå€æ°numberã®å€ãæŽæ°ããã³ãŒãã®æžãå¿ããçã«ãã
ãç¡éã«ãŒããé²ãâ
âäœãšãªããã«ãã³ã€ã€é¿ãâŠð€
ãð£foræãïŒç¶ã»ç¹°ãè¿ãåŠçïŒ
ðžwhileæããã·ã³ãã«
ãã確ãã«ïŒãã£ã€ãã·ã³ãã«ïŒïŒÎ£ïŒã»â¡ã»ïŒïŒ
ðžèšç®åŒã®çç¥
ãããªããšãåºæ¥ããªããŠâŠJavaãããäžäœäœè
ïŒïŒïŒ(ï¿£âï¿£;)
â ïž// foræãçšããŠã1ãã100ãŸã§ã®æ°åãåºåããŠãã ãã
for(let number=1;number<=100;number=number+1;){
console.log(number);
}ãããããããããããããããâæåŸã®ãïŒããããèŠããâ¡ïž
ãããããããããããããããããã
ãð£ç¹°ãè¿ãåŠçã®ãŸãšãã
ðžðžðžåæ°è¡šç€ºâïž
ã// foræãå®æãããŠãã ãã
for (let number = 1; number <= 100; number++) {
// ifæãçšããŠãnumberã3ã®åæ°ã®æã«ã3ã®åæ°ã§ãããããã§ãªããšãã¯æ°åãåºåããŠãã ãã
if (number % 3 === 0) {ãããããânumber*3ã§ãã£ãŠãâ ïž
console.log("3ã®åæ°ã§ã");
} else {ãããããããããããããã
console.log(number);ãããããã
}
}
â ïžããïŒ
ãã®éã¯ã ãäœããã衚瀺ãããããã®äœ¿çšäŸãåãããŸããïŒïŒ
ããŸãšãã
ã ãã ãå
容ãæ¿ããããããŸã§ã®äŒç·ãååããå§ããæ°é
ãæŒã£ãŠããŸãã⊠ç¡é§ãšæãããåãã£ãã€ããã«ãªãããèšé²ãæ®ãç¶ããããšæããŸãÙ©( 'Ï' )ÙãïŒæèŠæéïŒçŽ30ïœïŒ
ãã®èšäºãæ°ã«å ¥ã£ãããµããŒããããŠã¿ãŸãããïŒ