Skip to content

Instantly share code, notes, and snippets.

@Fahima1-2
Fahima1-2 / script.js
Created January 18, 2025 11:33
Untitled
const cars = ["toyota","honda","ford"];
console.log(cars.length);
const motorcycles = ["1","2","3","4","7"];
console.log(motorcycles.length)
const ages=[12,18,22,15,30];
const adults = ages.filter((age)=> age>= 18);
console.log(adults)
@Fahima1-2
Fahima1-2 / script.js
Created January 18, 2025 11:11
Untitled
const animals = ["cat","dog"];
animals.push("rabbit");
console.log(animals);
const colors = ["red","blue","green"];
colors[1] = "yellow";
console.log(colors);
const colores = ["brown"];
colores[1]="dark brown";
console.log(colores);
const cities = ["newyork","london","paris"];
@Fahima1-2
Fahima1-2 / script.js
Created January 14, 2025 13:01
Untitled
function leaveit(){
function contiInue(){
return "you look great!"
}
return contiInue();
}
console.log(leaveit())
@Fahima1-2
Fahima1-2 / script.js
Created January 14, 2025 12:29
Untitled
function outerfunction(){
function innerfunction(){
console.log("inner function executed!");
}
innerfunction();
}
console.log(outerfunction());
@Fahima1-2
Fahima1-2 / script.js
Created January 14, 2025 11:48
Untitled
function greet(name){
return 'Hello, Ahmad!'
}
console.log(greet("CodePen"));
function greet(){
console.log("you are good");
}
function add(a,b){
console.log(a+b);
}
@Fahima1-2
Fahima1-2 / script.js
Created January 10, 2025 11:51
Untitled
let counter = 0;
while (counter < 5){
if (counter === 3)
break;
console.log(counter);
counter ++;
}
let counter1 = 1;
while (counter1 < 10){
if (counter1 === 12)
@Fahima1-2
Fahima1-2 / script.js
Created January 10, 2025 11:33
Untitled
for (i = 5; i < 10; i ++){
console.log(i);
}
@Fahima1-2
Fahima1-2 / script.js
Created January 10, 2025 11:21
Untitled
let day = "Friday";
switch(day){
case "Sunday":
console.log("today is sunny");
break;
case "Tuesday":
console.log("today is rainy");
break;
case "Friday":
console.log("today is snowy");
@Fahima1-2
Fahima1-2 / script.js
Created January 10, 2025 11:09
Untitled
let worker = " ";
switch(worker){
case "a":
console.log("He must stay at home");
break;
case "b":
console.log("He must work out");
break;
case "c":
console.log("He is not talented");
@Fahima1-2
Fahima1-2 / script.js
Created January 10, 2025 10:56
Untitled
if (12 > 20){
console.log("he is old enough");
}else{
console.log( "you are false" );
}