javascriptの基本:else ifの使い方
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <title>else ifの使い方</title> </head> <body> <script type="text/javascript"> num = 1000; document.write(num + 'は'); if (0 <= num && num <= 9){ document.write('1桁の数です。'); } else if (10 <= num && num <= 99) { document.write('2桁の数です。'); } else if (100 <= num && num <= 999) { document.write('3桁の数です。'); } else { document.write('4桁以上です。'); } </script> </body> </html>