1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
yanalaym [24]
2 years ago
4

write a function fullwords(s) that returns a string no longer than 20 characters. if the string s is longer than 20 characters,

just truncate at the space closest to the 20th position (so no word is truncated) and return it. if the string s is shorter 20 characters, just return it unchanged.
Computers and Technology
1 answer:
Norma-Jean [14]2 years ago
4 0

Assuming you mean a function that truncates a string to 20 characters:

function fullwords(s){

if (s.length > 20) {

//find the 20th character

var char20 = s.charAt(19);

//if it's a space, return the string up to that point

if (char20 == " ") {

return s.substring(0, 20);

}

//if it's not a space, find the closest space

else {

var spaceBefore = s.lastIndexOf(" ", 18);

return s.substring(0, spaceBefore);

}

}

//if the string is shorter than 20 characters, return it unchanged

else {

return s;

}

}

To use fullwords(), simply pass in a string as the only argument. The function will then return a string that is no longer than 20 characters. If the string you passed in was shorter than 20 characters, it will be returned unchanged.

Learn more on string here:

brainly.com/question/28290531

#SPJ4

You might be interested in
Ultraportable computers will often use ___ technology exclusively, even though their storage capacity is lower than that of a tr
ki77a [65]

Answer:

SSD

Explanation:

8 0
2 years ago
Thomas is getting ready for a presentation. His slides are set, and he's
PIT_PIT [208]
B copy the web page of the video that you want to use
5 0
4 years ago
Use a search engine and spot the sponsored results for safer internet day.
snow_tiger [21]
What’s the question?
4 0
3 years ago
Which statement describes a characteristic of SRAM in a PC?
svlad2 [7]

It is used for cache memory.

Further Explanation:

Cache memory is the memory that stores the instructions and data that is used repeatedly. If the processor wants some data it first looks into cache memory then the processor doesn't has to look into the main memory for the data or instructions which is more time consuming. As the SRAM uses small but a constant source of power, it is usually used for making cache memories. Moreover it is benficial to keep the previously used data in SRAM(Which is faster) than acessing DRAM (Which is way more slow than SRAM.

  • Learn more about RAM in brainly.com/question/10602589
  • brainly.com/question/5159824
  • brainly.com/question/6062548

#LearnwithBrainly

8 0
3 years ago
You are creating a classification model from a DataFrame that contains data about traffic on highways in a US state, which conta
torisob [31]

Answer:

Split the data into two randomly sampled DataFrame,and then train the model with one DataFrame and test it with the other .As we have know labels in the data frame ,so this approch will give us a better picture on how accuractly our model is trained

Explanation:

Split the data into two randomly sampled DataFrame,and then train the model with one DataFrame and test it with the other .As we have know labels in the data frame ,so this approch will give us a better picture on how accuractly our model is trained

3 0
3 years ago
Other questions:
  • You have configured your organization's dhcp server to dynamically assign ip addresses to ghcp clients using a lease duration of
    5·1 answer
  • What is a swap file? how does the computer use this file? what information might be found there?
    6·1 answer
  • Why does the phrase "compatibility mode” appear when opening a workbook?
    6·2 answers
  • List the six external peripheral parts of a computer system
    8·1 answer
  • ARP only permits address resolution to occur on a single network.could ARP send a request to a remote server in an IP datagram?w
    9·1 answer
  • Murray University invested over $450,000 in a customized learning management system so that professors could put courses online
    9·1 answer
  • Which tool determines whether or not applications, devices, and computers will work with a new operating system, while maintaini
    13·1 answer
  • To celebrate me reaching expert in the same day i made the account im doing a point giveaway
    12·2 answers
  • If 2 people use my code D9R2M on fetch reward and scan receipts I will give brainliest ​
    13·2 answers
  • Why is it important to enforce access controls and to keep logs regarding who has access to data closets
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!