Skip to content

Commit

Permalink
Day 30: Functions
Browse files Browse the repository at this point in the history
  • Loading branch information
uttu-316 committed Nov 10, 2022
1 parent f6187d3 commit f931683
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 1 deletion.
2 changes: 1 addition & 1 deletion javascript/Day29/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ let min_array = [13, 40, 10, 5, 1, -1, -3, 12, 24];

let min = Infinity;

for (let i = 0; i < min_array.length - 1; i++) {
for (let i = 0; i < min_array.length; i++) {
const currentNumber = min_array[i];

if (currentNumber <= min) {
Expand Down
85 changes: 85 additions & 0 deletions javascript/Day30/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
let i = 0;

while (i < 3) {
//0<3
console.log(i);
i++;
}
console.log("End");

do {
console.log(i);
i++;
} while (i < 3); //1<3
console.log("End");

function my_function() {
console.log("Hello I am Function");
}

my_function();
function my_function(name, age) {
console.log("Hello I am" + " " + name + ", " + age);
}

my_function("Utkarsh", 24);

function printTable(value) {
let count = 1;

while (count <= 10) {
let answer = count * value;
console.log(value + " * " + count + " = " + answer);
count++;
}
}

let x = 2;

printTable(x);
printTable(y);
printTable(4);
printTable(5);
printTable(20);
printTable(12);

function fun(x, y, z = 10) {
console.log(x, y, z);
}

fun(2, 3);

fun(2, 3, 4);

function getSum(x, y, z) {
let sum = x + y + z;
return sum;
}

const result = getSum(2, 3, 4);

console.log(result);

function xyz() {
console.log("Utkarsh");
}

function abc(x) {
console.log(x);
xyz();
}

abc(2);

let z = 2;

function abc(my_function) {
const name = my_function();
console.log(name);
}

function xyz() {
return "Utkarsh";
}

abc(xyz);

0 comments on commit f931683

Please sign in to comment.