![]() Using this array is like using string buffer in some server side languages. if string is null or other than string this will fail. i can use an array and also add some checking. Is there any different way, you can reverse a string?Īnswer: sure. Interviewer: You know concatenation performed well in modern browsers but becomes slow in older browsers like IE8. Question: How would you reverse a string in JavaScript?Īnswer: I can loop through the string and concatenate letters to a new string try 1 ![]() If you are not applying for a Research post, you would be alright. Decision: divisor would be less than Math.sqrt (n)ĭon't worry! if you didnt get it.It is not divisible by 5, divisor should be less than 127/5 approximately 25 not by 7. So, you will check up to 127/3 approximately 42. 127 is not divisible by 2 hence you should check upto 63.5. step-3: For example u have the number 127.Decision: a number could be divisible by numbers 1/3 of its value.if you take an even number like 36 it will never be divisible by 13, 14, 15 hence it will be never divisible by any number bigger than 35/3 will never be divisible by 12, 13, 14. then it would be divisible any number bigger than the 1/3 of its value. (if it is divisible by 3, then it wouldn't be a prime number). step-2: Now, if a number is not divisible by 3.Decision: a number will never be divisible by a number bigger than half of its values.for example, 16 will be divisible by 8 but will never be by 9, 10, 11, 12. it could be as big as half of it for even number. for example, 13 will never be divisible by 7, 8, 9. step-1: Any number will not be divisible by a number bigger than half of it.If you are little more comfortable or claim to be comfortable with javascript, these questions would not be enough for you. More Questions CSS Interview Questions, HTML Interview Questions Find the largest sum of any two elements?.Check whether any two numbers in an array sums to a given number?.Find missing number from unsorted array of integers.Generate random between 5 to 7 by using defined function.Remove duplicate characters from a sting?. ![]() Find the first non repeating char in a string?. ![]() Swap two numbers without using a temp variable?.Remove duplicate members from an array?.Find the greatest common divisor of two numbers?.
0 Comments
Leave a Reply. |