What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-03-07 04:05:16
remove a specific item from an array javascript
var colors = ["red","blue","car","green"]; var carIndex = colors.indexOf("car");//get "car" index //remove car from the colors array colors.splice(carIndex, 1); // colors = ["red",&... Add solution -
Javascript 2022-03-06 21:00:04
javascript check if string contains at the begins with substring
var str = "We got a poop cleanup on isle 4."; if(str.indexOf("poop") !== -1){ alert("Not again"); } //use indexOf (it returns position of substring or -1 if not found) Add solution -
Javascript 2022-03-06 00:30:47
convert rgb value in hexadecimal system
function convertRgb(rgb) { // This will choose the correct separator, if there is a "," in your value it will use a comma, otherwise, a separator will not be used. var separator = rgb.indexOf(",") > -1 ? "," : &quo... Add solution -
C# 2022-03-03 11:15:21
sum array c#
int[] arr = new int[] { 1, 2, 3 }; int sum = 0; for (int i = 0; i < arr.Length; i++) { sum += arr[i]; } int[] arr = { 3, 6, 4, 1, 6, 8 }; // returns 1 Array.IndexOf(arr, 6); int maxValue = anArray.Max(); int maxIndex = anArray.ToList().IndexOf(m... Add solution -
Javascript 2022-02-28 23:00:04
how to delete the array in javascript
var colors = ["red","blue","car","green"]; var carIndex = colors.indexOf("car");//get "car" index //remove car from the colors array colors.splice(carIndex, 1); // colors = ["red",&... Add solution -
Javascript 2022-02-28 19:35:03
javascript get browser name
//gets the type of browser function detectBrowser() { if((navigator.userAgent.indexOf("Opera") || navigator.userAgent.indexOf('OPR')) != -1 ) { return 'Opera'; } else if(navigator.userAgent.indexOf("Chrome") != -1 ... Add solution -
Java 2022-02-27 11:05:21
java rename file extension
// java rename file extension import java.io.File; import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; public class RenameFileExtension { public static boolean renameExtension(String strSource, String strNewExte... Add solution -
Javascript 2022-02-27 05:40:22
8.3.1. Common Array Methods // indexOf Examples (.indexOf)
//The general syntax for this method is: arrayName.indexOf(item) /*This method returns the index of the FIRST occurence of an item in the array. If the item is not in the array, -1 is returned.*/ let charles = [1, 7, 5, 9, 5]; let otherArray = ['hello',... Add solution