DEV Community

loading...

"while loop developer" how to use pug/jade, scss, javascript, python(backend) - (Stack Tutorial 2)

nikhilroy2 profile image Nikhil Chandra Roy ・1 min read

Hi guyes,
This is tutorial 2,
The previous tutorial we have learnt how to use for loop pug/jade, scss, javascript, python(backend) Here you can see
This tutorial we will use basic while loop in our stack web development.

1. PUG/JADE
In this pug/jade tutorial we can use this pug to html converter for practice purpose PUG TO HTML

Example 1

- var i=0
ul
 while i < 10
  li= i++


Enter fullscreen mode Exit fullscreen mode

2. SCSS

Example 1

$border: 1;
@while $border < 10+1{
    li:nth-child(#{$border}){
        border: #{$border}px solid red;

    }
    $border: $border+1
}

Enter fullscreen mode Exit fullscreen mode

3. Javascript
while loop
Example 1

let li = document.querySelectorAll('li');
let i = 0;
while(i < li.length){
    li[i].style.color = 'yellow';
    console.log(i)
    i++;
}
Enter fullscreen mode Exit fullscreen mode

while loop with do (js)
Example 2

do{
    li[i].style.color = 'yellow';
    console.log(i)
    i++;
}
while(i < li.length)

Enter fullscreen mode Exit fullscreen mode

"do" and while is very simple to use and the "while" making the condition and the "do" execute the callback.

Finally, Python
4. Python

Example 1

count = 0
while count < 10:
    print(count)
    count+=1

Enter fullscreen mode Exit fullscreen mode

It almost looks little same as javascript but python has only 2 primitive loop

  • For
  • while

This is my sort tutorial hope you like it.
if you like this sort tutorial please like, comments.
Thanks.

Discussion (0)

Forem Open with the Forem app