Skip to main content

Command Palette

Search for a command to run...

#1.Basic algorithms problems for frontend developers.

Published
โ€ข1 min readโ€ขView as Markdown
#1.Basic algorithms problems for frontend developers.
T

I am a developer from Cape Town,South Africa

There are many many ways to solve the below algorithms but I am just using the more readable ones. I will share 1 algorithm per post to allow sufficient engagement. If you have any other solutions you can always post the in the comments section.

  1. Reverse a string without using revers() JavaScript method.
const str = 'Hello world';

const reversString = string => {
  // first - create a new helper string
  let stringReversed = '';

  // second - split the string to get an array from it
  const arrFromString = string.split('');

  // third - loop trough the array
  for (let el of arrFromString) {
    /* forth add each letter from the array 
  in front of the empty helper sting*/
    stringReversed = el + stringReversed;
  }
  // fifth - return the new reversed string
  return stringReversed;
};

More from this blog

Javascript E๐—บ๐—ฝ๐˜๐˜† ๐—ผ๐—ฏ๐—ท๐—ฒ๐—ฐ๐˜ ๐—ฎ๐˜€ ๐—ฎ ๐—ณ๐—ฎ๐—น๐—น๐—ฏ๐—ฎ๐—ฐ๐—ธ ๐˜„๐—ต๐—ถ๐—น๐—ฒ ๐—ฑ๐—ฒ๐˜€๐˜๐—ฟ๐˜‚๐—ฐ๐˜๐˜‚๐—ฟ๐—ถ๐—ป๐—ด

As explained in one of my posts in the Javascript series, you can use the optional chaining operator to simplify and avoid breaking code So the below code: ๐˜ค๐˜ฐ๐˜ฏ๐˜ด๐˜ต ๐˜ถ๐˜ด๐˜ฆ๐˜ณ = { ๐˜ฏ๐˜ข๐˜ฎ๐˜ฆ: '๐˜‹๐˜ข๐˜ท๐˜ช๐˜ฅ' }; ๐˜ค๐˜ฐ๐˜ฏ๐˜ด๐˜ต ๐˜ด๐˜ต๐˜ณ๐˜ฆ๐˜ฆ๐˜ต๐˜•๐˜ข๐˜ฎ๐˜ฆ = ๐˜ถ๐˜ด๐˜ฆ๐˜ณ....

Jun 7, 20221 min read
Javascript E๐—บ๐—ฝ๐˜๐˜† ๐—ผ๐—ฏ๐—ท๐—ฒ๐—ฐ๐˜ ๐—ฎ๐˜€ ๐—ฎ ๐—ณ๐—ฎ๐—น๐—น๐—ฏ๐—ฎ๐—ฐ๐—ธ ๐˜„๐—ต๐—ถ๐—น๐—ฒ ๐—ฑ๐—ฒ๐˜€๐˜๐—ฟ๐˜‚๐—ฐ๐˜๐˜‚๐—ฟ๐—ถ๐—ป๐—ด

The simplest and modern to avoid an error while displaying fetched data in Javascript

๏ฟฝ ๐—ง๐—ต๐—ฒ ๐˜€๐—ถ๐—บ๐—ฝ๐—น๐—ฒ๐˜€๐˜ ๐—ฎ๐—ป๐—ฑ ๐—บ๐—ผ๐—ฑ๐—ฒ๐—ฟ๐—ป ๐˜„๐—ฎ๐˜† ๐˜๐—ผ ๐—ฎ๐˜ƒ๐—ผ๐—ถ๐—ฑ ๐—ฒ๐—ฟ๐—ฟ๐—ผ๐—ฟ ๐˜„๐—ต๐—ถ๐—น๐—ฒ ๐—ฑ๐—ถ๐˜€๐—ฝ๐—น๐—ฎ๐˜†๐—ถ๐—ป๐—ด ๐—ณ๐—ฒ๐˜๐—ฐ๐—ต๐—ฒ๐—ฑ ๐—ฑ๐—ฎ๐˜๐—ฎ ๐—ถ๐˜€ ๐˜‚๐˜€๐—ถ๐—ป๐—ด ๐—ก๐˜‚๐—น๐—น๐—ถ๐˜€๐—ต ๐—ฐ๐—ผ๐—ฎ๐—น๐—ฒ๐˜€๐—ฐ๐—ถ๐—ป๐—ด ๐—ผ๐—ฝ๐—ฒ๐—ฟ๐—ฎ๐˜๐—ผ๐—ฟ (??) โœ”๏ธ ๐˜›๐˜ฉ๐˜ฆ ๐˜ฏ๐˜ถ๐˜ญ๐˜ญ๐˜ช๐˜ด๐˜ฉ ๐˜ค๐˜ฐ๐˜ข๐˜ญ๐˜ฆ๐˜ด๐˜ค๏ฟฝ...

Jun 3, 20221 min read
The simplest and modern to avoid an error while displaying fetched data in Javascript

4 Helpful Javascript Array tricks you should know

An array is one of the most common concepts of Javascript, which gives us a lot of possibilities to work with data. Check these tricks which can be very helpful! ๐Ÿ‘‰ ๐—Ÿ๐—ฒ๐˜โ€™๐˜€ ๐—ด๐—ฒ๐˜ ๐˜€๐˜๐—ฎ๐—ฟ๐˜๐—ฒ๐—ฑ ๐Ÿง‘โ€๐Ÿ’ป ๐ŸŒถ๏ธ ๐—›๐—ผ๐˜„ ๐˜๐—ผ ๐—ฟ๐—ฒ๐—บ๐—ผ๐˜ƒ๐—ฒ ๐—ณ๐—ฎ๐—น๐˜€๐˜† ๐˜ƒ๐—ฎ๐—น๏ฟฝ...

Jun 2, 20221 min read
G

GenesisDigitalZA

5 posts