Conquer the JavaScript Interview: Steps [Beginner Skill Level]

preview_player
Показать описание
Link to this Playlist:

This is a part of my Algorithms and Data Structures playlist series. We cover a lot of common interview questions asked during whiteboards for entry level developers. Learning to master these takes time, practice, and pattern recognition. So I'll be helping you equip a toolbelt and filling it with as many tools as I can to help prepare you crush those interviews! Remember: "Luck is where practice meets opportunity."

In this video we cover a fun algorithm, printing steps. This is an algorithm you find across any programming book or course, and one a newbie may actually be asked to tackle in an interview! As with all these, understanding the basics lets you solve it quicker than you think. Anyone coming from our Catalyst Prep course or Intro to Web Development have already "basically" done this particular one in the 99 Lines of Code lab. This function uses two nested for loops to build each step, adding “#” characters up to the current step number and spaces for the rest of the line. The outer loop controls the height of the steps, while the inner loop controls the width. The result is a series of steps that look like a staircase when printed to the console.

Don't forget to like this video and subscribe to our channel – we're publishing more videos and walkthroughs every week. Comment below and let us know what you'd like to see next!

#algorithms #javascript #interview #interviewtips #steps
Рекомендации по теме
Комментарии
Автор

function printsteps(n){
If(n===0)return;
var steps='';
var i= 1;
while(i<=n){
steps +='#';
console.log(steps);
i++;
}
}

mohamadcheaib
Автор

We can use array or string concatination and one while loop for this solution

mohamadcheaib
Автор

Couldn’t you also cut 3 lines by making your for condition in the second loop width<=Height? This would allow you to avoid the if else

ooyufmc
Автор

This can be done in one loop using string function repeat.

andrewwall
join shbcf.ru