Tech Finder
数字を入力してください。
以下が実際のプログラムです。セキュリティ脆弱性を排除するために、evalは使用しません。
<!DOCTYPE html>
<html>
<head>
<title>Tech Finder</title>
<meta charset="UTF-8">
</head>
<body>
<h1>Tech Finder</h1>
<p>数字を入力してください。</p>
<input type="text" id="numInput">
<button onclick="findTech()">検索</button>
<div id="techList">
</div>
<script>
function findTech() {
const num = parseInt(document.getElementById("numInput").value);
// 1 ~ 10に対応するテクノロジーのリスト
const techList = [
["iOS", "iPhone", "iPad", "macOS", "Safari", "iCloud", "Apple Watch", "Apple Music", "AirPods", "App Store"],
["Android", "Chrome", "Google Play", "Google Drive", "Google Maps", "YouTube", "Google Photos", "Pixel", "Google Assistant", "Google Pay"],
["Windows", "Office", "Internet Explorer", "Outlook", "Skype", "Microsoft Teams", "Surface", "OneDrive", "Visual Studio", "Xbox"],
["Facebook", "Instagram", "WhatsApp", "Messenger", "Oculus", "Portal", "Spark AR", "Boomerang", "Layout", "Threads"],
["Java", "JavaScript", "Python", "C++", "PHP", "Ruby", "Swift", "Kotlin", "Objective-C", "Scala"],
["Tesla", "Autopilot", "Powerwall", "Solar Roof", "Supercharger", "Tesla Energy", "Hyperloop", "The Boring Company", "Tesla Roadster", "Gigafactory"],
["Amazon", "Kindle", "Alexa", "Echo", "Fire TV", "Ring", "Twitch", "Prime Video", "AWS", "S3"],
["Netflix", "Stranger Things", "Black Mirror", "The Crown", "Narcos", "Bird Box", "Making a Murderer", "Money Heist", "The Witcher", "You"],
["TikTok", "ByteDance", "Douyin", "Musical.ly", "Toutiao", "Xigua Video", "Lark", "Helo", "TopBuzz", "BaBe"],
["Zoom", "Webinar", "Meeting", "Conference Room", "Screen Sharing", "Recording", "Breakout Rooms", "Virtual Background", "Polling", "Waiting Room"]
];
// 入力された数字に対応するテクノロジーのリストを取得
const index = num - 1;
const techs = techList[index];
// テクノロジーのリストをHTMLに表示
const techListDiv = document.getElementById("techList");
techListDiv.innerHTML = "";
for (let i = 0; i < techs.length; i++) {
const tech = techs[i];
const techItem = document.createElement("p");
techItem.textContent = tech;
techListDiv.appendChild(techItem);
}
// 業界に関するジョークを表示
const jokes = [
"プログラマーとオタクは同じようにコンピューターに熱中しているが、オタクは頻繁に再起動をする。",
"エンジニアにとって最も最高の瞬間は、テストスクリプトをクリックした瞬間の『緑色』である。",
"IT業界では、常に最新技術が使われているわけではない。30年以上前の技術が今日でも使われていることがある。",
"『また問題が発生した』という言葉が一般的になるのは、インターネット接続がより一般的になったためだ。",
"プログラマーにとって『働くとは』、コードを書いていない時でもコードを考えていることである。",
"ファイル共有ミスはIT業界の天敵である。"],
const jokeIndex = Math.floor(Math.random() * jokes.length);
alert(jokes[jokeIndex]);
}
</script>
</body>
</html>