Video není dostupné.
Omlouváme se.
#18 While vs For Loop | Which to use and When?
Vložit
- čas přidán 2. 06. 2021
- Instagram : / navinreddyofficial
Linkedin : / navinreddy20
Discord : / discord
More Learning :
Java - bit.ly/3xleOA2
Python :- bit.ly/3H0DYHx
Django :- bit.ly/3awMaD8
Spring Boot :- bit.ly/3aucCgB
Spring Framework :- bit.ly/3GRfxwe
Servlet & JSP :- bit.ly/3mh5CGz
Hibernate Tutorial :- bit.ly/3NWAKah
Rest API | Web Service Tutorial :- bit.ly/38RJCiy
Git :- bit.ly/3NUHB3V
JavaScript :- bit.ly/3mkcFys
Kotlin :- bit.ly/3GR2DOG
the answer is :
let num = 123456;
let num2="0";
while(num>0)
{
let remainder=num%10;
num2=num2*10+remainder;
num=parseInt(num/10);
}
console.log(num2);
Assignment:
let num = 123456;
let num2 = 0;
while(num>0)
{
let num1= num % 10;
num2 = num2 *10 + num1;
num = parseInt(num/10);
}
console.log(num2);
Time stamp 1:14 //numbers 1 to 100 that are divisible by 3
let count = 0; // to contain how many numbers are divisible by three
for (let i = 1; i
Best teacher on youtbe, Kudos to navin sir
Thanks for clearance I’ve been asking myself even my friends when and where to apply a certain loop method on projects. Then today am the one who’s gonna help others on that one. Watching different tutorials with different developers helps me a lot because I learn 10 times more than at school.
assignment:-
let num = 28374983;
let reverse = "";
while (num > 0) {
console.log(num % 10);
reverse += num % 10;
num = parseInt(num / 10);
}
convert = parseInt(reverse);
console.log(convert, typeof convert);
Thanks
Answer 6:25
//Made by Anmol main
let value = 564782
let rev
while (value) {
rev = value % 10;
value = parseInt(value / 10)
console.log(rev);
}
Didn't get it there is no condition in while
@@nihaltiwari3474 yes
numbers divisible by 3 for(int i = 3;i
Thanks Navin!!
Here are Positive order loop i wrote.
let x=56789
let y=10000
while(y>=1)//Positive order
{
z=parseInt(x/y)
console.log(parseInt(z%10))
y=y/10;
}
Very nice explaination.
by learning JS from here, can we become more familiar with development using js? and this playlist covers all the advanced points which a programmer should known for development ?? kindly help anyone
We will use if statement in for loop and condition is if(i%3==o) then print the value of i
For outputing a range of numbers divisible by 3 you dont need that condition (i%3===0). You can simply increment the 'i' in your for loop by 3 and get same result. ie: -
for(let i = 0; i < 100; i += 3){
console.log(i)
}
i = 1
bro how can one get rid of the zero in the output
@@AbelKimutai-cp9gh use a condition eg if i > 0
Nice explanation
can we add && operator to for loop?
my forloop never gets xecuted i need help
The mystey is solved...😂. Thx mate
Good stuff
Very nice series Sir ... Hope you will cover till advanced of JavaScript, One request sir ... please make a dedicated series on DevOps ... Website Deployment, Docker, Kubernetes, Jenkins, Especially Azure or AWS please sir ...
Super 👍
Very very very nice bro
HW:
let num = 564782, num2 = 0;
while(num > 0)
{
num2 = (num2 * 10) + (num % 10);
num = parseInt(num / 10);
}
console.log(num2);
Once Again Thanks Navin sir
Sir, please make videos on Artificial intelligence and machine learning
please tell about best books for javascript
Nice your explanation is amazing sir, and am a fan of you.
Please make a video on java interview questions for freshers
Thanks.
last question
let num1=3927193
num2=""
while (0
>>6:16 Answer0)
{
value=num%10;
temp=10*temp+value;
num=parseInt(num/10);
}
console.log(temp);
You are going to make a video on Dom or not
let num = 398595
let rev = ""
while(num>0)
{
let rem=num%10
rev=String(rev)+String(rem)
num=parseInt(num/10)
}
console.log(rev);
Answer at 6:18 time stamp
let rev = 0;
let num = 12345;
rev = Number(String(num).split(' ').reverse( ).join(' '));
console.log(rev);
ouput is
54321
while(num > 0)
{
ld = num % 10;
rev = rev*10 + ld;
num = num / 10;
}
1.19 // print the number divided by 3 between 1 to 100
for (let i = 1; i
assignment
small change inside ur code while loop
num2 = num2*10;
num2 += num1℅10;
a very well known in C and C++...
Do while loop
Timeline:1:20
for(let i=1;i
In String->
let num=12345;
let num2="";
while(num>0){
num2+=String(num%10);
num=parseInt(num/10);
}
console.log(num2);
at 1:19
for(let i = 1; i
Hi my friend
let num = 56782;
let num2=0;
while(num>0)
{
console.log(num%10);
num= parseInt(num/10);
}
console.log(num2)
my answer for the homework at the end
Sir what software you used edit video
Anna vedios continue chey anna..🥲
Sir this is a great playlist, but it's been 1 month and the video is still covering javascript basic syntax. Please proceed with the web part soon, really looking forward to it from you :)
Noo, these basics are used everywhere
Hello bro I am manoj from Hyderabad(Telengana) could please suggest me that how can I improve my communication skills like you.Could we have some talk
for(i = 0; i
let num = 123456
for(;num>0;)
{
console.log(num%10)
num = parseInt(num /10)
}
The for loop still woked
I want to know one thing even without let why js works
Time stamp 1:14
for (let i=1; i
I mean bro you're just cool
let num = 564782
let num2 = 0
while ( num > 0 ) {
console.log(num % 10 );
num = parseInt(num / 10 )
num2 = num
}
1:13
I don't have my computer right now so I am just explaining it
if i is % 3 and === 0 than console.log
Peace out ✌️
1st view and comment
// Reversing a number
let num = 123456;
let rev = 0;
let rightDigit = 0;
while (num > 0) {
rightDigit = parseInt(num % 10);
rev = rev * 10 + rightDigit;
num = Math.floor(num / 10);
}
console.log(rev);
//6:40 (assignment)
let num = 1234;
let num2= "0";
while(num>0)
{
let remainder = num%10;
num = parseInt(num/10);
num2= String (num2 + remainder);
}
console.log(Number(num2)); // output is 4321
Super bro with string concatenation
you are smart
Output will be :04321
Because you have assigned num2 = "0"
let num2= "0"; exchange let num2 ='"". if let num2 ="0" output is 04321
ANSWER FOR 1:14
for(let i=1;i
I have deleted node js and I know c++ so I answered questions answer in c++
#include
int main(int argc, char *argv[])
{
int num=252257;
int num2=1;
while(num>0){
int lastDigit=num%10;
num2=num2*10+lastDigit;
num/=10;
}
std::cout
2:52 how did you come with divide 123456 by 10 to get 6?
@telusko
if we divide 123456 by 10, then the output is 12345.6. But in video percentage symbol (%) is used. The % symbol gives the remainder when 123456 is divided by 10. In this case, the output is 6.
let num = 12345
let digit = 0
let reversedDigit = ""
while(num > 0){
digit = num % 10
num = parseInt(num / 10)
reversedDigit = reversedDigit + String(digit)
}
console.log(`The reverse number is:
${reversedDigit}`)
6:16 assignment
let num = 564782, num2 = 0;
while(num > 0)
{
console.log((num2 * 10) + (num % 10));
num = parseInt(num / 10);
}
console.log(num2);
output comes as expected vertically
let num =123456;
let num2=0;
while(num>0)
{
let rem = num%10;
num2 = num2*10+rem;
num = parseInt(num/10);
}
console.log(num2);
does anyone know why
console.log(num%10) print 6?
because % returns the remainder value so, when you do 123456 / 10, remainder would be 6.
let num = 123456;
let num2 = 0;
while(num>0){
q = num / 10;
r = num % 10;
num = parseInt(q);
num2 = (num2*10) + r;
}
console.log(num2)
Ist viewer and first liker
/*digits of an integer --using java */
import java.util.*;
public class SampleClass {
public static void main(String[]arg) {
Scanner scr=new Scanner(System.in);
System.out.println("enter the number");
int n=scr.nextInt();
digitinteger(n);
}
static void digitinteger(int n) {
int arr[]=new int[100];
int i=0;
int r=0;
while(n>0) {
r=n%10;
arr[i]=r;
i++;
n=n/10;
}
for(int j=i-1;j>=0;j--) {
System.out.println(arr[j]);
}
}
}
1:08
let num;
for(let i=1;i
The reverse of the given Number code:
let num=564782
let Str=""
while(num>0){
Str+=String(num%10)
num=parseInt(num/10)
}
console.log(Str)
**Not the assignment** splitting the number in the same order not in the reverse order as shown in the video.
let r=564782;
t=100000;
while(r>0)
{
a=parseInt(r/t);
k=parseInt(r%t);
console.log(a);
t=t/10;
r=k;
}
this is the best method, i have also doing this straight numbers in same orders. thanks for the code.
let num = 123456789
let num2 = ""
while(num>0){
output = String(num%10)
num2 = num2 + output
num = parseInt(num/10)
}
console.log(num2)
Reverse Output
let reverseNum = 564782;
let stringNum = reverseNum.toString();
for(let i=0; i< stringNum.length; i++){
let reversed = parseInt(stringNum[i])
console.log(reversed);
}
"Yesterday is history".
"Tomorrow is mystery".
"Today is a gift ".
"That's why is called present😎✌️🤟"
num = 1234
let reverse = 0
while (num>0)
{
reverse = reverse*10+(num%10);
num = parseInt(num / 10);
}
console.log(reverse);
Your examples in this presentation are just too complicated. Keep it simple man.
let num1 = 28405
let num2 = 0
while(num1>0){
num2 = num2*10 + num1%10
console.log(num1%10);
num1 = parseInt(num1/10)
}
console.log(num2);
let newNum = 0;
let num = 1234;
while (num > 0) {
newNum = (num % 10) + (newNum * 10);
num = parseInt(num / 10);
}
console.log(newNum)
let num=1234;
let sum=0;
let rem=0;
while(num>0)
{
rem=num%10;
sum=sum*10+rem;
num=num/10;
}
console.log(sum); //4321
Thanks for this amazing series !!
The answer for the assignment at 6:34 is
let num = 4567;
let rev = 0;
while(num > 0) {
rev = rev*10 + (num%10)
num = parseInt(num /10)
}
console.log(rev) //7654
nice. could you explain the logic?
let num = 16548765412;
let arr = [];
let q = 1;
while(q>=1)
{
r = num % 10;
q = num / 10;
num=Math.floor(q);
arr.push(r)
}
len = arr.length
while(len>=0)
{
console.log(arr[len])
len--
}
for(let i=1, i
for(let x= 0; x
for (let i = 1; i
for(i=1;i
for(let i=1;i
for (i = 1; i
for (let i = 1; i
for(let i = 0; i
for odd numbers
for (let i = 0; i
Why use parseInt and not math.floor
?
for(let i = 1; i