function Pasta(grain, size, shape) {
this.grain = grain; // Assigning the grain property of the Pasta object.
this.size = size; // Assigning the size property of the Pasta object.
this.shape = shape; // Assigning the shape property of the Pasta object.
}
var spaghetti = new Pasta("wheat", 2, "circle"); // Creating a new Pasta object named spaghetti.
var names = Object.getOwnPropertyNames(spaghetti).filter(CheckKey); // Getting the property names of spaghetti and filtering them based on the CheckKey function.
document.write(names); // Writing the filtered property names to the document.
// Check whether the first character of a string is 's'.
function CheckKey(value) {
var firstChar = value.substr(0, 1); // Extracting the first character of the string.
if (firstChar.toLowerCase() == 's') // Checking if the first character is 's'.
return true; // Returning true if the first character is 's'.
else
return false; // Returning false otherwise.
}