3. Ten Simple JavaScript Exercises
3 of 10 simple JavaScript exercises. http://www.ling.gu.se/~lager/kurser/webtechnology/lab4.html
by Lisa French
HTML
<div id="console-log"></div>
JavaScript
//Hack to mimic console within JSFiddle
var consoleLine = "<p class=\"console-line\"></p>";
console = {
log: function (text) {
$("#console-log").append($(consoleLine).html(text));
}
};
//Begin exercise
var testChars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
var vowels = ['a', 'e', 'i', 'o', 'u'];
for (var i = 0; i < testChars.length; i++) {
var vowel = 'false (' + testChars[i] + ' is not a vowel)';
for (var j = 0; j < vowels.length; j++) {
if (testChars[i] === vowels[j]) {
vowel = 'true (' + testChars[i] + ' is a vowel)';
}
}
console.log(vowel);
}