<aside>
<img src="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a5a1e3ce-00fa-46e4-9a75-58c2aed9e8ce/Notion_Fundamentals_with_Thomas_Frank_-_Avatar_2021.png" alt="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a5a1e3ce-00fa-46e4-9a75-58c2aed9e8ce/Notion_Fundamentals_with_Thomas_Frank_-_Avatar_2021.png" width="40px" /> The splice()
function removes a number of elements from a list a specified starting index. Optionally, you can add any number of new elements at that starting index as well. The function returns a new list that reflects the changes (it does not modify the original list).
Created by Thomas Frank | Learn Notion Formulas | Notion Basics | Templates | Twitter
</aside>
lets(
startingList, [1, 2, 4, 4, 5],
fixedList, startingList.splice(2, 1, 3),
"Starting list: [ " +
startingList.join(", ") +
" ]\\nEnding list: [ " +
fixedList.join(", ") + " ]"
)
lets(
startingList, ["articuno", "bulbasaur", "farfetch'd"],
fixedList, startingList.splice(2, 0, "charmander", "dugtrio", "ekans"),
"Starting list: [ " +
startingList.join(", ") +
" ]\\nEnding list: [ " +
fixedList.join(", ") + " ]"
)
lets(
startingList, [1, 2, 3, 4, 2],
fixedList, startingList.splice(-1, 1, 5),
"Starting list: [ " +
startingList.join(", ") +
" ]\\nEnding list: [ " +
fixedList.join(", ") + " ]"
)
lets(
startingList, [1, 2, 1, 8, 2],
fixedList, startingList
.splice(-1, 1, 9)
.splice(2, 1, 3, 4, 5, 6, 7),
"Starting list: [ " +
startingList.join(", ") +
" ]\\nEnding list: [ " +
fixedList.join(", ") + " ]"
)