What do you want to save?
Add Code snippet
New code examples
-
Python 2022-03-03 06:20:01
how to print a list nicely python
# Creating a list. Can also be floats and intagers list = ["a", "b", "c", "d", "e", "f", "g"] # Have a for loop and then print the answer index of the variable in the loop(i) for i in ... 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 -
C++ 2022-02-26 16:45:35
string
#A string is a type of data. There are many data types. It can be manipulated. #It can be storerd as a variable myString = "Hello world" #WE can print it: print(myString) #You can append it to arraY: myArr = [] myArr.append(myString) #You can fi... Add solution -
Javascript 2022-02-19 10:35:24
array map
const myArray = ['Sam', 'Alice', 'Nick', 'Matt']; // Appends text to each element of the array const newArray = myArray.map(name => { return 'My name is ' + name; }); console.log(newArray); // ['My name is Sam', 'My Name is Alice', ...] // Appends ... Add solution -
C# 2022-02-17 18:15:26
indexof c#
// To find the index of the first substring in a string use // 'IndexOf()' string str = "Hello World!" str.IndexOf("o"); // Output: 4 // You can give a starting index and a length to search at str.IndexOf("o", 6, 4); // Outp... Add solution -
Python 2022-02-13 16:10:17
pop function python
my_list = [123, 'Add', 'Grepper', 'Answer'] my_list.pop() -->[123, 'Add', 'Grepper'] #last element is removed my_list = [123, 'Add', 'Grepper', 'Answer'] my_list.pop(0) -->['Add', 'Grepper', 'Answer'] #first element is removed my_list = [123, 'Add... Add solution -
Javascript 2022-02-12 05:25:18
how to update specific key of an object in reducer
case COMPLETE_TODO: { const index = state.todos.findIndex(todo => todo.id === action.payload); //finding index of the item const newArray = [...state.todos]; //making a new array newArray[index].completed = true//changing value in the new array... Add solution