gpt4 book ai didi

javascript - 从字符串JS中的最后一个提取子字符串

转载 作者:行者123 更新时间:2023-11-29 19:50:35 25 4
gpt4 key购买 nike

<分区>

我需要编写 JS 函数,如果字符串的最后一个包含 - depreciated 则返回 true,否则返回 false。

例如:

var somestring = "string value - depreciated";

在上面的例子中,函数应该返回 true。

function isDepreciated(var S)
{
//Need to check for substring in last
//return true or false
}

一种可能的解决方案是使用 search 函数,但这意味着如果 - depreciated 出现在字符串中,那么它也将返回 true。我真的需要找到天气子串是否在最后。

请帮忙。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com