Write a simple function (less than 80 characters) that returns a boolean indicating whether or not a string is a palindrome.(JAVA SCRIPT)

The following one line function will return true if str is a palindrome; otherwise, it returns false. function isPalindrome(str) { str = str.replace(/\W/g, ”).toLowerCase(); return (str == str.split(”).reverse().join(”)); } For example: console.log(isPalindrome(“level”)); // logs ‘true’ console.log(isPalindrome(“levels”)); // logs ‘false’ console.log(isPalindrome(“A car, a man, a maraca”)); // logs ‘true’ Continue reading Write a simple function (less than 80 characters) that returns a boolean indicating whether or not a string is a palindrome.(JAVA SCRIPT)

Check IMEI Number by Luhn algorithm.

check digit (d9) = [7x(d1 + d4 + d7) + 3(d2 + d5+ d8) + 9(d3 + d6)] mod 10 The check digit is validated in three steps: Starting from the right, double a digit every two digits (e.g., 5 → 10). Sum the digits (e.g., 10 → 1+0). Check if the sum is divisible by 10. Conversely, one can calculate the IMEI by choosing the check digit that would give a sum divisible by 10. For example: IMEI 49015420323751? IMEI 4 9 0 1 5 4 2 0 3 2 3 7 5 1 ? Double every other 4 … Continue reading Check IMEI Number by Luhn algorithm.

Total number of ways to call default parameter in c#.

Default parameter is a way to pass default value to a method when less argument is passing. this can be achieve by 4 ways. I) method overloading 2) using [OPTIONAL] keyword 3) using param keyword(it should be the last argument) 4)assigned at the time of declaration example: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Runtime.InteropServices; namespace ConsoleApplication6 { class Program { static void Main(string[] args) { addition obj = new addition(); Console.WriteLine( obj.add(1));//output 2 Console.WriteLine(obj.add());// Console.WriteLine(obj.add(3, 4)); Console.WriteLine(obj.add1(a: 1, c: 2));// addition obj1 = new addition(); Console.WriteLine (obj1.sub(4, 1)); Console.WriteLine (obj1.sub(1)); addition obj2 = new addition(); … Continue reading Total number of ways to call default parameter in c#.

Write a c# program that calculate the length of string without using anyinbuilt function.

string str = “wordcounter”; str += ‘\0’; int x = 0; while (str[x] != ‘\0’) x++; Console.WriteLine(x); you could write a loop and increment a counter inside this loop: int numberOfLetters = 0; foreach (var c in str) { numberOfLetters++; } // at this stage numberOfLetters will contain the number of letters // that the string contains there is also another way: int numberOfLetters = str.ToCharArray().Length; Continue reading Write a c# program that calculate the length of string without using anyinbuilt function.

Explicitly Insert in an Identity Column in SQL

1. Explicitly Insert in an Identity Column in SQL –>CREATE TABLE products (id int IDENTITY PRIMARY KEY, product varchar(40)) GO — Inserting values into products table. INSERT INTO products (product) VALUES (‘screwdriver’) INSERT INTO products (product) VALUES (‘hammer’) INSERT INTO products (product) VALUES (‘saw’) INSERT INTO products (product) VALUES (‘shovel’) GO select * from products — Create a gap in the identity values. DELETE products WHERE product = ‘saw’ GO — Attempt to insert an explicit ID value of 3; — should return a warning. INSERT INTO products (id, product) VALUES(3, ‘garden shovel’) GO — SET IDENTITY_INSERT to ON. SET … Continue reading Explicitly Insert in an Identity Column in SQL

Remove Duplicate Rows in SQL

Remove Duplicate Rows in SQL –>CREATE TABLE [Employee]( [ID] INT NOT NULL, [Email] [varchar](50) NOT NULL ); –drop table dbo.Employee INSERT INTO [dbo].[Employee] VALUES (1,’test1@gmail.com’); INSERT INTO [dbo].[Employee] VALUES (2,’test1@gmail.com’); INSERT INTO [dbo].[Employee] VALUES (3,’test2@gmail.com’); INSERT INTO [dbo].[Employee] VALUES (4,’test2@gmail.com’); INSERT INTO [dbo].[Employee] VALUES (5,’test3@gmail.com’); INSERT INTO [dbo].[Employee] VALUES (6,’test1@gmail.com’); INSERT INTO [dbo].[Employee] VALUES (7,’test3@gmail.com’); GO —-SELECT MAX(ID),EMAIL,ROW_NUMBER() OVER (Order By EMAIL ASC) AS ‘ROW’ –FROM EMPLOYEE –GROUP BY EMAIL –before deleting SELECT * FROM EMPLOYEE GO WITH T1 AS ( SELECT ID FROM DBO.EMPLOYEE EXCEPT SELECT MAX(ID) AS ID FROM DBO.EMPLOYEE GROUP BY Email HAVING COUNT(Email) > 1 ) … Continue reading Remove Duplicate Rows in SQL