Ashley Singh

Ashley Singh

  • NA
  • 13
  • 1.2k

Struggling with Angular Interview Questions

Mar 30 2023 6:24 AM

Hi everyone,

I'm new to Angular development and I'm struggling with interview questions related to the framework. I've read through all of the documentation and angular article and tutorials I can find but I still feel really lost when it comes to coding challenges.

For example, I was recently asked to write a function that takes two strings and returns the longest common substring between them. I wrote the following code, but it's not working correctly - can someone please help me figure out where I'm going wrong?

function longestCommonSubstring(string1, string2) {
  let longestSubstring = '';
 for (let i = 0; i < string1.length; i++) {
    for (let j = 0; j < string2.length; j++) {
      let currentSubstring = '';
      let k = 0;
 
      while (string1[i + k] === string2[j + k]) {
        currentSubstring += string1[i + k];
        k++;
      }
      if (currentSubstring.length > longestSubstring.length)

 


Answers (2)