#17: TypeScript Tuples🔥Mastering Data Structures| Best Practices & Examples

preview_player
Показать описание
Welcome 🎉 In this typescript tutorial, I have a special surprise in store for you! 🎁 Watch the video as we deep dive into the world of TypeScript and explore the powerful concept of Tuples.

😊 Become Member, get access to perks, free Source code, & more..

⌚TIMELINE⌚
00:00 - Introduction
00:26 - Special Surprise
01:20 - Locating Homework on the Website
02:20 - Exploring Tuples in TypeScript
04:08 - Real-life Practical Examples of Tuples
05:50 - Advantages of Using Tuples over Arrays
06:35 - Implementing Functions with Tuple Values
09:03 - Executing Our Program
09:40 - Best Practice: Utilizing Readonly Properties
11:45 - Homework Assignment

************* 😍 Must Watch Videos For Web Development 😍 *************

Рекомендации по теме
Комментарии
Автор

great awesome...Please make video on ecommerce and job site using next 13

BillaSaheb
Автор

hello, sir I have got an error which (changed 1 package in 5s) couldn't install can you help what is issue ?

sahibdadsakhizada
Автор

please share the extension that you are using

ravikantjha
Автор

Need electron.js in 2024 course, plz ❤

Ahmad-edjr
Автор

isme jo ye [...data] hai console ke ander uska kya use hai ?

maddeveloper
Автор

Good Job but still you didn't explain how this auto type declaring the typescript on screen automatically

meshahan
Автор

/* Question 3 */
type WeatherData = readonly [string, number, string];
let cities: any[] = [];

let city1: WeatherData = ['Surat', 30, 'overcast'];
let city2: WeatherData = ['Ahmedabad', 34, 'sunny'];
let city3: WeatherData = ['Rajkot', 27, 'rainy'];

cities.push(city1, city2, city3);

const displayWeather = (cities: any[]) => {
let cityInfo: object[] = [];
cities.forEach((city) => {
let [name, celsius, condition] = city;
cityInfo.push({ City: name, Temperature: celsius, Condition: condition });
});
console.table(cityInfo);
};
displayWeather(cities);

DhruvinS
Автор

why (person:PersonInfo)=>void have repeated twice in 8:54
can anybody please explain me

raghua
Автор

Q3. Answer:
type WeatherData = readonly [string, number, string]
let allData:any[] = []
const city1 = ['Kolkata', 35, 'Hot'];
const city2 = ['Mumbai', 20, 'Moderate'];
const city3 = ['Jammu', 12, 'Cold'];
allData.push(city1);
allData.push(city2);
allData.push(city3);

allData.map((ele, i)=>{
console.log(`City: ${ele[0]}, Temp in C: ${ele[1]}, Condition: ${ele[2]}.`)
})

can you please tell me how to take user input in TS?

anirbanchatterjee
Автор

ye kitni gandi extension install ki hoi hy. ye extension bohat zeada confusion padaa kar rahii hy please isko remove karo Thapa Technical

terabapaya
Автор

Dear Thapa bhai, I hope you don't mind, but I noticed that the organization of your React JS playlist could be improved. The serial numbers for the videos are not clear, and it's causing some difficulty for me to understand. On the other hand, 'Harry' bhai has done a great job with clear serial numbers for the videos. I hope you understand, and I apologize if my feedback comes across as critical. Thank you!

CrazyAshu
Автор

Question 1:

type ProductName = readonly [string, number, number]


const disprod = (info:ProductName):void =>{
const [prname, price, quantity] = info;
console.log(`Product name: ${prname}, Price ${price}, Quantity ${quantity}`)
}

const prod1:ProductName = ["Soap", 25, 9]
const prod2: ProductName= ["Hairbrush", 89, 21]

disprod(prod1)
disprod(prod2)


Question 2:
type SubjectGrade = [string, number, string, number, string, number]

const average = (student:SubjectGrade):void =>
{

const [subname1, grade1, subname2, grade2, subname3, grade3] = student;
console.log(`Subject name: ${subname1}, Grade: ${grade1},
Subject name: ${subname2}, Grade: ${grade2},
Subject name: ${subname3}, Grade: ${grade3}` )
const vari = (grade1 + grade2 + grade3)/3;
console.log("The average is:", vari.toFixed(2))

}

const sub1:SubjectGrade = ["Math", 30, "EVS", 40, "SSC", 70]

average(sub1)

Qusestion 3 :

type WeatherData = readonly [string, number, string];
let cities: any[] = [];

let city1: WeatherData = ['Surat', 30, 'overcast'];
let city2: WeatherData = ['Ahmedabad', 34, 'sunny'];
let city3: WeatherData = ['Rajkot', 27, 'rainy'];

cities.push(city1, city2, city3);

const displayWeather = (cities: any[]) => {
let cityInfo: object[] = [];
cities.forEach((city) => {
let [name, celsius, condition] = city;
cityInfo.push({ City: name, Temperature: celsius, Condition: condition });
});
console.table(cityInfo);
};
displayWeather(cities)

saurabhkamble
Автор

Ans 1.
type ProductInfo = readonly [string, number, number];

const displayProductInfo = (product:ProductInfo) => {
const [name, price, quantity] = product;
console.log(`The name of the product is ${name} price is ${price} and you ordered ${quantity} quantity`);
}

const product1:ProductInfo = ["Horlicks", 250, 10];
const product2:ProductInfo = ["KitKat", 10, 10];

displayProductInfo(product1);
displayProductInfo(product2);


DEEPANSHU_NAG
Автор

Q1
type ProductsInfo = readonly [string, number, number, ]

const product1:ProductsInfo = ['Smart Phone', 15000, 23];
const product2:ProductsInfo = ['Watch', 100, 12];

function
const [Product_Name, price, stocks] = product
console.log(`Product Name : ${Product_Name}, Price : ${price}, Stocks : ${stocks}`)
}

displayProductInfo(product1)
displayProductInfo(product2)


Q2

type SubjectGrade = readonly [string, number, ]

const subject1:SubjectGrade = ['Math', 95]
const subject2:SubjectGrade = ['English', 85]
const subject3:SubjectGrade = ['Science', 90]

function calculateAverage(subject1:SubjectGrade, subject2:SubjectGrade, subject3:SubjectGrade){
const[Subject1_Name, Grade1] = subject1
const[Subject2_Name, Grade2] = subject2
const[Subject3_Name, Grade3] = subject3
const averageGrade = (Grade1+Grade2+Grade3)/3
console.log(`Average Grade is ${averageGrade}`)
}

calculateAverage(subject1, subject2, subject3)


Q3

type WeatherData = [string, number, string]

const city1:WeatherData = ['Patna', 31, 'Haze'];

function
const[city_name, tem, type] = city
console.log(`Temperature in ${city_name} is ${tem}°C and Weather type is ${type}`)
}

displayweather(city1);

ballagtech