是否有可能在JavaScript中爲數組中的每個字符串創建自動子串? 例如:javascript:爲數組中的每個字符串創建自動子串
var test =
[
"banana",
"apple",
"pear",
"cologne"
];
var conclusion = prompt("choose one")
// something that would get the following result:
if(conclusion === banana)
{
print("b");
print("ba");
print ("ban");
// ...
print("banana");
// and the same for the rest of the strings in the Array.
瞭解循環和字符串函數。 – SLaks
是的,這是可能的。 –