要查找总共 140 个字符中剩余的字符数,slice 函数
To find how many characters are remaining from a total of 140, slice function
为此,我在下面编写了代码
var tweet = prompt("compose your tweet");
var tweetcount = tweet.length;
alert("you have written " + tweetcount + " characters you have " + (140 - tweetcount) + " characters remaining. ");
var tweet = "cut down your tweet";
tweetcount.slice(141, 1);
虽然它有效地给出了写入提示,然后告诉了剩余的字符数+字符数限制。
但是在控制台为什么说 tweetcount.slice
不是函数?
var tweet = prompt ("compose your tweet"); var tweetunder140 = tweet.slice(0,140); alert(tweetunder140);
为此,我在下面编写了代码
var tweet = prompt("compose your tweet");
var tweetcount = tweet.length;
alert("you have written " + tweetcount + " characters you have " + (140 - tweetcount) + " characters remaining. ");
var tweet = "cut down your tweet";
tweetcount.slice(141, 1);
虽然它有效地给出了写入提示,然后告诉了剩余的字符数+字符数限制。
但是在控制台为什么说 tweetcount.slice
不是函数?
var tweet = prompt ("compose your tweet"); var tweetunder140 = tweet.slice(0,140); alert(tweetunder140);