Это видео недоступно.
Сожалеем об этом.
#18 While vs For Loop | Which to use and When?
HTML-код
- Опубликовано: 2 июн 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);
Best teacher on youtbe, Kudos to navin sir
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
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.
We will use if statement in for loop and condition is if(i%3==o) then print the value of i
numbers divisible by 3 for(int i = 3;i
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
Very nice explaination.
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;
}
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
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
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
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 ...
Sir, please make videos on Artificial intelligence and machine learning
Nice explanation
The mystey is solved...😂. Thx mate
can we add && operator to for loop?
Please make a video on java interview questions for freshers
Nice your explanation is amazing sir, and am a fan of you.
my forloop never gets xecuted i need help
please tell about best books for javascript
Very very very nice bro
Super 👍
Good stuff
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
1.19 // print the number divided by 3 between 1 to 100
for (let i = 1; i
You are going to make a video on Dom or not
assignment
small change inside ur code while loop
num2 = num2*10;
num2 += num1℅10;
a very well known in C and C++...
while(num > 0)
{
ld = num % 10;
rev = rev*10 + ld;
num = num / 10;
}
Thanks.
I want to know one thing even without let why js works
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
//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
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 ✌️
last question
let num1=3927193
num2=""
while (0
Do while loop
let num = 398595
let rev = ""
while(num>0)
{
let rem=num%10
rev=String(rev)+String(rem)
num=parseInt(num/10)
}
console.log(rev);
>>6:16 Answer0)
{
value=num%10;
temp=10*temp+value;
num=parseInt(num/10);
}
console.log(temp);
at 1:19
for(let i = 1; i
for(i = 0; i
Sir what software you used edit video
let num = 123456
for(;num>0;)
{
console.log(num%10)
num = parseInt(num /10)
}
The for loop still woked
In String->
let num=12345;
let num2="";
while(num>0){
num2+=String(num%10);
num=parseInt(num/10);
}
console.log(num2);
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
I mean bro you're just cool
Anna vedios continue chey anna..🥲
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
Hi my friend
Timeline:1:20
for(let i=1;i
let num = 564782
let num2 = 0
while ( num > 0 ) {
console.log(num % 10 );
num = parseInt(num / 10 )
num2 = num
}
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
Time stamp 1:14
for (let i=1; i
1:08
let num;
for(let i=1;i
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.
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
ANSWER FOR 1:14
for(let i=1;i
// 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);
/*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]);
}
}
}
let num =123456;
let num2=0;
while(num>0)
{
let rem = num%10;
num2 = num2*10+rem;
num = parseInt(num/10);
}
console.log(num2);
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 = 123456;
let num2 = 0;
while(num>0){
q = num / 10;
r = num % 10;
num = parseInt(q);
num2 = (num2*10) + r;
}
console.log(num2)
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}`)
1st view and comment
Ist viewer and first liker
let num = 123456789
let num2 = ""
while(num>0){
output = String(num%10)
num2 = num2 + output
num = parseInt(num/10)
}
console.log(num2)
**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.
"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.
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)
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);
}
for(let x= 0; x
for(let i=1, i
for(let i=1;i
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 = 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
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
for(let i = 0; i
for(i=1;i
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?
for (i = 1; i
for (let i = 1; i
for odd numbers
for (let i = 0; i
Why use parseInt and not math.floor
?
for(let i = 1; i