JSFiddle - React, Tailwind, and code Playground
by John Brown
HTML
<div><strong>Sorted Fruit:</strong> <span id="sorted-fruit"></span>
</div>
<div><strong>Capitalized Fruit without Cs:</strong> <span id="capitalized-fruit"></span>
</div>
JavaScript
// (1) Iterate through each fruit type and write it to the console
// using a for loop.
// (2) Use Array's methods "sort" and "join" to print an alphabetically
// sorted comma delimited list of fruit in the span with id "sorted-fruit"
// (3) Use ECMAScript 5 Array methods "filter" and "map" and Array method
// "join" to print out a comma delimited list of fruit that are
// capitalized (just the first letters); skip those that contain the
// letter "c" in them.
var fruit = [
"apple",
"orange",
"peach",
"cherry",
"pear",
"apricot",
"banana",
"guava",
"melon"];
for(var i in fruit){
console.log(fruit[i]);
}
var str = fruit.sort().join([seperator = ',']);
document.getElementById("sorted-fruit").innerHTML = str;
var element = fruit.sort().map(function(ele){return ele.charAt(0).toUpperCase()+ ele.slice(1)}).join(', ')
document.getElementById("capitalized-fruit").innerHTML = element;