Search string value in an array
<head>
<title></title>
<script type="text/javascript">
var stars = ["A","B","C"];
var constells = ["a","b","c"];
function searchValue(star) {
for (var i = 0; i < stars.length; i++) {
if (stars[i] == star) {
return constells[i];
}
}
return star + " Not Found.";
}
</script>
</head>
<body>
<script type = "text/javascript" >
var v = "A";
document.write(searchValue(v));
</script>
</body>
Related examples in the same category