Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Js #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Js #2

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions scripts.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
//Use this file to implement Part One of your project
var animal = {};

animal.username = "Mittens";

animal['tagline'] = 'Pet me!';

var noises = [];

animal.noises = noises;

var count = 0;
for (var key in animal) {
count++;
if (key === 'username') {
console.log('hi my name is ' + animal[key]);
} else if (key === 'tagline') {
console.log('I like to say ' + animal[key]);
}
}

//Arrays

var noiseArray = ['purr', 'oink'];

noiseArray.unshift('Ezra');
noiseArray.push('Chiang');

noiseArray[3] = 'growl';

noiseArray['hello'] = 'GMAN';

animal.noises = noiseArray

var animals = [];

animals.push(animal);

// functions

function AnimalTestUser(user) {
var args = arguments.length;
var otherArgs = [];
if (args > 1) {
for (var i=1; i<args; i++) {
otherArgs.push(arguments[i]);
}
}

return {
username: username,
otherArgs: otherArgs
};
}

//higher order functions