Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
AkramFlutterdev committed Feb 14, 2024
1 parent 8ea8e4e commit 349c8e0
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 50 deletions.
6 changes: 3 additions & 3 deletions 0x12-javascript-warm_up/1-multi_languages.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/node
console.log('C is fun');
console.log('Python is cool');
console.log('Javascript is amazing');
console.log("C is fun");
console.log("Python is cool");
console.log("Javascript is amazing");
26 changes: 13 additions & 13 deletions 0x12-javascript-warm_up/10-factorial.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#!/usr/bin/node
const args = process.argv.slice(2);
function factorial(n) {
if (isNaN(n)) {
return 1;
}
n = parseInt(n, 10);
function factorial (n) {
if (isNaN(n)) {
return 1;
}
n = parseInt(n, 10);

if (n === 0 || n === 1) {
return 1;
} else {
return n * factorial(n - 1);
}
if (n === 0 || n === 1) {
return 1;
} else {
return n * factorial(n - 1);
}
}
const input = args[0];
const result = factorial(input);
if (!isNaN(result) && isFinite(result)) {
console.log(result);
console.log(result);
} else {
console.log("Infinity");
}
console.log('Infinity');
}
6 changes: 3 additions & 3 deletions 0x12-javascript-warm_up/101-call_me_moby.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/node

function callMeMoby(x, theFunction) {
for (let i = 0; i < x ; i++) {
function callMeMoby (x, theFunction) {
for (let i = 0; i < x; i++) {
theFunction();
}
}
}
module.exports.callMeMoby = callMeMoby;
6 changes: 3 additions & 3 deletions 0x12-javascript-warm_up/102-add_me_maybe.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/node

function addMeMaybe(number, theFunction) {
theFunction(number+1);
function addMeMaybe (number, theFunction) {
theFunction(number + 1);
}
module.exports.addMeMaybe = addMeMaybe;
module.exports.addMeMaybe = addMeMaybe;
26 changes: 13 additions & 13 deletions 0x12-javascript-warm_up/103-object_fct.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/node
const myObject = {
type: 'object',
value: 12
};
console.log(myObject);
myObject.incr = function () {
myObject.value += 1;
}
myObject.incr();
console.log(myObject);
myObject.incr();
console.log(myObject);
myObject.incr();
console.log(myObject);
type: 'object',
value: 12
};
console.log(myObject);
myObject.incr = function () {
myObject.value += 1;
};
myObject.incr();
console.log(myObject);
myObject.incr();
console.log(myObject);
myObject.incr();
console.log(myObject);
6 changes: 3 additions & 3 deletions 0x12-javascript-warm_up/3-value_argument.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/node

const args = process.argv.slice(2);
if (args.length === 0) {
const args = process.argv;
if (!args[2]) {
console.log('No Argument');
} else {
console.log(args[0]);
console.log(args[2]);
}
2 changes: 1 addition & 1 deletion 0x12-javascript-warm_up/6-multi_languages_loop.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/node

const array = ['C is fun', 'Python is cool', 'JavaScript is amazing'];
for (i = 0; i < array.length; i++) { console.log(array[i]); }
for (let i = 0; i < array.length; i++) { console.log(array[i]); }
21 changes: 10 additions & 11 deletions 0x12-javascript-warm_up/8-square.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

const args = process.argv.slice(2);
const size = parseInt(args[0], 10);
if(args.length === 0 || !Number.isInteger(size) || Number.isNaN(size)){
console.log('Missing size');
} else{
for(let i = 0; i < size ; i++){
let row = "";
for(let j = 0; j < size; j++){
row += "X";
}
console.log(row);
}
if (args.length === 0 || !Number.isInteger(size) || Number.isNaN(size)) {
console.log('Missing size');
} else {
for (let i = 0; i < size; i++) {
let row = '';
for (let j = 0; j < size; j++) {
row += 'X';
}
console.log(row);
}
}

0 comments on commit 349c8e0

Please sign in to comment.