[ This is a content summary only. Visit our website http://bit.ly/1b4YgHQ for full links, other content, and more! ]
by Zia Zaidi via Digital Information World
"Mr Branding" is a blog based on RSS for everything related to website branding and website design, it collects its posts from many sites in order to facilitate the updating to the latest technology.
To suggest any source, please contact me: Taha.baba@consultant.com
The ways tech interviews are being carried out has been at the center of much controversy for a while now. It’s a sensitive topic, especially when it comes to coding challenges.
Not all companies use the same screening process, but for the most part, expect to be asked to solve a coding challenge, either on a suitable platform or on the dreaded whiteboard.
One complaint that’s usually made against coding challenges is that they’re mostly irrelevant to the day-to-day tasks the actual job requires. Especially when it comes to front-end interview questions, sometimes it’s curious how what’s missing in the interview are just front-end-related questions on things like browser compatibility, layout methods and DOM events. While this can be true, those who favor this approach and are responsible for hiring in these companies often say something like this:
I’d rather hire a smart person and teach them X than hire someone who knows everything about X but lacks creativity, logic, and reasoning. — Interviewing as a Front-End Engineer in San Francisco
Whatever we feel about the way candidates are screened for dev jobs, at the time of writing, coding challenges are still a big part of the interview process.
In this article, I’m going to show how you can tackle five common coding challenges you might be asked when interviewing for a JavaScript or front-end Junior Developer position. They’re not among the hardest ones you could come across in the interview process, but the way you approach each of them could make the difference between success and failure.
Before diving into the challenges, let’s go through some tips about how you could approach your tech interview.
It’s likely that you’ve come across one or more of the challenges I’ve listed below, either during a job interview or while practicing your JavaScript skills. What better reason is there for getting really good at solving them?
Let’s get cracking!
A palindrome is a word, sentence or other type of character sequence which reads the same backward as forward. For example, “racecar” and “Anna” are palindromes. “Table” and “John” aren’t palindromes, because they don’t read the same from left to right and from right to left.
The problem can be stated along the following lines: given a string, return true if the string is a palindrome and false if it isn’t. Include spaces and punctuation in deciding if the string is a palindrome. For example:
palindrome('racecar') === true
palindrome('table') === false
This challenge revolves around the idea of reversing a string. If the reversed string is the same as the original input string, then you have a palindrome and your function should return true. Conversely, if the reversed string isn’t the same as the original input string, the latter is not a palindrome and your function is expected to return false.
Here’s one way you can solve the palindrome challenge:
const palindrome = str => {
// turn the string to lowercase
str = str.toLowerCase()
// reverse input string and return the result of the
// comparisong
return str === str.split('').reverse().join('')
}
Start by turning your input string into lower case letters. Since you know you’re going to compare each character in this string to each corresponding character in the reversed string, having all the characters either in lower or upper case will ensure the comparison will leave out this aspect of the characters and just focus on the characters themselves.
Next, reverse the input string. You can do so by turning the string into an array using the String’s .split() method, then applying the Array’s .reverse() method and finally turning the reversed array back into a string with the Array’s .join() method. I’ve chained all these methods above so the code looks cleaner.
Finally, compare the reversed string with the original input and return the result — which will be true or false according to whether the two are exactly the same or not.
This is a super popular coding challenge — the one question I couldn’t possibly leave out. Here’s how you can state the problem.
The FizzBuzz challenge goes something like this. Write a function that does the following:
Example:
fizzBuzz(5)
Result:
// 1
// 2
// fizz
// 4
// buzz
One important point about FizzBuzz relates to how you can find multiples of a number in JavaScript. You do this using the modulo or remainder operator, which looks like this: %. This operator returns the remainder after a division between two numbers. A remainder of 0 indicates that the first number is a multiple of the second number:
12 % 5 // 2 -> 12 is not a multiple of 5
12 % 3 // 0 -> 12 is multiple of 3
If you divide 12 by 5, the result is 2 with a remainder of 2. If you divide 12 by 3, the result is 4 with a remainder of 0. In the first example, 12 is not a multiple of 5, while in the second example, 12 is a multiple of 3.
With this information, cracking FizzBuzz is a matter of using the appropriate conditional logic that will lead to printing the expected output.
Here’s one solution you can try out for the FizzBuzz challenge:
const fizzBuzz = num => {
for(let i = 1; i <= num; i++) {
// check if the number is a multiple of 3 and 5
if(i % 3 === 0 && i % 5 === 0) {
console.log('fizzbuzz')
} // check if the number is a multiple of 3
else if(i % 3 === 0) {
console.log('fizz')
} // check if the number is a multiple of 5
else if(i % 5 === 0) {
console.log('buzz')
} else {
console.log(num)
}
}
}
The function above simply makes the required tests using conditional statements and logs out the expected output. What you need to pay attention to in this challenge is the order of the if … else statements. Start with the double condition first (&&) and end with the case where no multiples are found. This way, you’ll be able to cover all bases.
The post How to Beat 5 Common JavaScript Interview Challenges appeared first on SitePoint.
This sponsored article was created by our content partner, BAW Media. Thank you for supporting the partners who make SitePoint possible.
WordPress plugins offer easy ways to add or extend the functionality of a WordPress site. There are hundreds of these plugins on the market. But which ones you choose will generally be determined by the type or niche of your website. Although a few of them are helpful or even necessary for any website you design.
Adding or improving on a website's functionality generally involves a great deal of work. We talk about the designer and the developer. Plugins can do all the work for you — great news if you're a WordPress aficionado.
Having a few "must-have" plugins on hand is always a good idea. Not every one of those listed here will be essential in your case. Yet, there are at least several you really don't want to be without.
That being the case – we're pleased to share these top plugins and tools with you.
Not every website requires charts and tables to get its message across, but the minute you find yourself attempting to create one that does, you'll want a tool that makes the process as easy as possible; one that does it right and saves you a ton of time in the process.
If average is good enough, and you're not pressed for time, there are plenty of chart/table building tools to choose from.
If, however, you want –
wpDataTables gives you an all-in-one solution for working with large amounts of data and is the only chart/table-building solution fully supporting MySQL, MS SQL, and PostgreSQL databases.
Designed for businesses that heavily depend on appointment bookings, Amelia ensures appointment can be made any time, correctly and trouble-free, and properly managed.
The post 10 Popular Plugins to Extend or Enhance Your WordPress Site appeared first on SitePoint.