Skip to content

Instantly share code, notes, and snippets.

View claudiainbytes's full-sized avatar
😺
I build awesome digital stuff

Claudia Estupiñán Forero claudiainbytes

😺
I build awesome digital stuff
View GitHub Profile
//When you encapsule a function inside an object that
//function is called as a method whenever you need. Example:
//The object projects
var projects = {
"projects": [{
"title": "Project 1",
"description": "Lorem ipsum dolor sit amet"
},
{
var clickLocations = [];
function logClicks(x,y) {
clickLocations.push(
{
x: x,
y: y
}
);
console.log('x location: ' + x + '; y location: ' + y);
var work = {
"jobs": [
{
"employer": "Udacity",
"title": "Course Developer",
"location": "Mountain View, CA",
"dates": "Feb 2014 - Current",
"description": "Who moved my cheese cheesy feet cauliflower cheese. Queso taleggio when the cheese comes out everybody's happy airedale ricotta cheese and wine paneer camembert de normandie. Swiss mozzarella cheese slices feta fromage frais airedale swiss cheesecake. Hard cheese blue castello halloumi parmesan say cheese stinking bishop jarlsberg."
},
{
var name = "AlbERt EINstEiN";
function nameChanger(oldName) {
var finalName = oldName;
// Your code goes here!
finalName = finalName.toLowerCase();
finalName = finalName.split(" ");
finalName = finalName[0].charAt(0).toUpperCase() + finalName[0].slice(1) + " " + finalName[1].toUpperCase();
var sampleArray = [0,0,7];
var incrementLastArrayElement = function(_array) {
var newArray = [];
// Your code should make newArray equal to an array that has the same
// values as _array, but the last number has increased by one.
// For example:
// _array = [1, 2, 3];
// turns into:
var s = "audacity";
var udacityizer = function(s) {
// Right now, the variable s === "audacity"
// Manipulate s to make it equal to "Udacity"
// Your code goes here!
s = s.charAt(1).toUpperCase() + s.slice(2);
return s;
};
/*
* Programming Quiz: Donuts Revisited (7-6)
*/
var donuts = [
{ type: "Jelly", cost: 1.22 },
{ type: "Chocolate", cost: 2.45 },
{ type: "Cider", cost: 1.59 },
{ type: "Boston Cream", cost: 5.99 }
];
/*
* Programming Quiz: Facebook Friends (7-5)
*/
// your code goes here
var facebookProfile = {
name: "Claudia",
friends: 100,
messages: ["Happy birthday", "I love you", "XOXO", "Bless you"],
/*
* Programming Quiz: Bank Accounts 1 (7-3)
*/
var savingsAccount = {
balance: 1000,
interestRatePercent: 1,
deposit: function addMoney(amount) {
if (amount > 0) {
savingsAccount.balance += amount;
/*
* Programming Quiz: Nested Numbers (6-10)
*
* - The `numbers` variable is an array of arrays.
* - Use a nested `for` loop to cycle through `numbers`.
* - Convert each even number to the string "even"
* - Convert each odd number to the string "odd"
*/
var numbers = [