I had never heard of the comma operator. Thanks for the video!
@AllThingsJavaScript2 жыл бұрын
Glad to help
@ketankulkarni26752 жыл бұрын
I always learn something new in your videos. thanks
@AllThingsJavaScript2 жыл бұрын
Glad to hear it!
@TillmanTech2 жыл бұрын
Great video! I had to watch it several times and run the code myself to get the concepts. Love it! I don't think of using reduce() as often as I should. Thank you and much appreciated!!!
@AllThingsJavaScript2 жыл бұрын
Glad it was helpful!
@aabirsabil4393 Жыл бұрын
Great video
@sairamn28632 жыл бұрын
Great content sir.. very helpful 🎉😊
@mariummagdy43592 жыл бұрын
thank you so much
@AllThingsJavaScript2 жыл бұрын
Welcome 😊
@josearmandozeballosduran70862 жыл бұрын
Nullish coalescing operator, it works with logical or ||... And it also works with logical And??... If you want to understand this solution better go deeper with the coalescing operator. Nice video thanks 👍
@Adel_Gs Жыл бұрын
👌🏻👌🏻✅ Bravo
@Uncaught_in_promise2 жыл бұрын
Great tutorial. This could be done also with ES5 methods like for loop.
Somebody help me in this problem Please write solution in javascript Write a function called do_allocation(number_of_people, number_of_buses) The function should return a list of number of people who can get into the next bus that comes in based on the following logic: Each bus’s capacity is the sum of the capacities of the previous two buses. Once all the people get in, then the buses can continue, but will have 0 people inside it. This is the case when the number of people are less and there are more buses. So after all the people are already boarded, then the remaining buses will have 0 people boarding. The output of the function is an array/list with the same length as number_of_buses. The total of this output array/list should be less than or equal to the number_of_people. The first bus’ capacity can be set to 1 by default. E.g. Def do_allocation(number_of_people, number_of_buses): …. Your code…. Return array[number of people got into first bus, number of people got into second bus, …. , number of people who got into last bus]
@AllThingsJavaScript2 жыл бұрын
The number of people per bus sounds like solving a fibonacci sequence: kzbin.info/www/bejne/pJi2ZpSQi9Kkpc0 Once you have that down I think the other parts can be figured out. See if that tutorial helps.
@coder-webdev59072 жыл бұрын
@@AllThingsJavaScript I solved this like that it is nice way or how can i make it easy to understand .? // Number of People and Number of Buses let person, buses; // i = number of iterations when passengers are not in the bus // j = number of iterations when passengers are less than the next sum // n1 = passengers in the first bus // n2 = passengers in the first bus // sum = n1 + n2 // total = number of passengers boarded // exceedLim = total number exceeding real numbers of passengers let i, j, n1 = 1, n2 = 1, sum, total = 1, exceedLim; const resultArray = [1]; // Result Array with (1st bus capacity = 1). // Function to provide elements to Result Array const do_Allocation = (person, buses) => { // For loop for passengers to get into the bus with complete sum for (i = 1; i < buses; i++) { sum = n1 + n2; // sum of first two buses' passenger count total += n2; // total number of passengers onboard n1 = n2; // changing the first bus identity to second bus n2 = sum; // changing the second bus identity to the next bus resultArray[i] = n1; // insertion of passenger count in the bus exceedLim = total + n2; // keeping track of sum exceeding the people // if sum exceeds then iterations stop to proceed into the // incomplete sum array insertions if (exceedLim > person) { break; }; }; // For loop for passengers to get into the bus with incomplete sum for (j = i+1; j < buses; j++) { if (j==i+1) { // insertion of rest passenger on the bus resultArray[j] = person - total; } else { // insertion of the wmpty bus value, i.e. 0 in the empty buses resultArray[j] = 0; }; }; return resultArray; }; // call the function with people and buses attributes console.log('Result Array: ' + do_Allocation(70, 13));
@AllThingsJavaScript2 жыл бұрын
@@coder-webdev5907 Great job solving the problem! These types of problems are a great way to learn code.