Skip to content

Commit

Permalink
all done for javascripting
Browse files Browse the repository at this point in the history
  • Loading branch information
anandujjwal13 committed Jan 19, 2017
1 parent bb55b82 commit 77cbe1d
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 8 deletions.
2 changes: 2 additions & 0 deletions accessing-array-values.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var foodsArray = ['apple', 'pizza', 'pear'];
console.log(foodsArray[1]);
5 changes: 5 additions & 0 deletions array-filtering.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var numbersArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
var filteredArray = numbersArray.filter(function isEven(element) {
return (element % 2) === 0;
});
console.log(filteredArray);
2 changes: 2 additions & 0 deletions array-program.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var pizzaToppingsArray = ['tomato sauce','cheese','pepperoni'];
console.log(pizzaToppingsArray);
7 changes: 7 additions & 0 deletions for-loop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var total = 0 ,limit = 10;
for (var i = 0; i < limit; i++) {

total+=i;

}
console.log(total);
8 changes: 8 additions & 0 deletions fruit-length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var fruit = 'orange';
var fruitNameLength = fruit.length;
if (fruitNameLength > 1) {
console.log('The fruit name has more than five characters.');
}
else {
console.log('The fruit name has five characters or less.');
}
4 changes: 4 additions & 0 deletions function-arguments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function math(number1, number2, number3) {
return (number2 * number3) + number1;
}
console.log(math(53, 61, 67));
4 changes: 4 additions & 0 deletions functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function eat(food) {
return food + ' tasted really good.';;
}
console.log(eat('bananas'));
5 changes: 5 additions & 0 deletions looping-through-arrays.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var petsArray = ['cat', 'dog', 'rat'];
for (var i = 0; i < petsArray.length; i++) {
petsArray[i] = petsArray[i] + 's';
}
console.log(petsArray);
5 changes: 5 additions & 0 deletions num-to-string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var demoNum = 128;
demoNumString = demoNum.toString();
console.log(demoNumString);
var numToStringLength = demoNumString.length;
//console.log(numToStringLength);
4 changes: 2 additions & 2 deletions numbers.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
var example = 123456789;
console.log(example);
var demoNum = 123456789;
console.log(demoNum);
4 changes: 4 additions & 0 deletions object-properties.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var foodObject = {
types: 'only pizza'
};
console.log(foodObject.types);
12 changes: 12 additions & 0 deletions objects.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// var pizzaObject = {
// toppingsArray: ['cheese', 'sauce', 'pepperoni'],
// crustString: 'deep dish',
// servesCount: 2
// };

var pizzaObject = {
toppings: ['cheese', 'sauce', 'pepperoni'],
crust: 'deep dish',
serves: 2
};
console.log(pizzaObject);
6 changes: 3 additions & 3 deletions revising-string.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
var example = 'pasta is wonderful';
example = example.replace('pasta', 'pizza');
console.log(example);
var stringReplace = 'pasta is wonderful';
stringReplace = stringReplace.replace('pasta','pizza');
console.log(stringReplace);
6 changes: 3 additions & 3 deletions rounding-numbers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
var roundUp=1.5;
roundUp=Math.round(roundUp);
console.log(roundUp);
var roundUp = 1.5;
roundUpNum = Math.round(roundUp);
console.log(roundUpNum);
18 changes: 18 additions & 0 deletions scope.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var a = 1, b = 2, c = 3;

(function firstFunction(){
var b = 5, c = 6;

(function secondFunction(){
var b = 8;
console.log("a: "+a+", b: "+b+", c: "+c);
(function thirdFunction(){
var a = 7, c = 9;

(function fourthFunction(){
var a = 1, c = 8;

})();
})();
})();
})();

0 comments on commit 77cbe1d

Please sign in to comment.