Resources
Answers
Examples
Sign in
Get Started
What do you want to save?
Add Code snippet
New code examples
Javascript
2021-09-23 03:41:03
javascript truncate string full word
const truncate = (str, max, suffix) => str.length < max ? str : `${str.substr(0, str.substr(0, max - suffix.length).lastIndexOf(' '))}${suffix}`; // Example truncate('This is a long message', 20, '...');
Add solution
Javascript
2021-09-22 10:03:02
how to get file extension in javascript last index
var extension = fileName.substring(fileName.lastIndexOf('.')+1);
Add solution
Javascript
2021-09-21 13:32:02
duplicate encoder
const duplicateEncode = word => { let newString = '' word = word.toLowerCase() || word word.split('').filter((x, index) => { if(word.indexOf(x) !== index){ newString += ')' }else if(word.lastIndexOf(x) !== index){ ...
Add solution
Javascript
2021-09-21 08:50:01
javascript get current directory
var loc = window.location.pathname; var dir = loc.substring(0, loc.lastIndexOf('/'));
Add solution
Javascript
2021-09-21 05:16:02
get last path segment of url in javascript
console.log(this.href.substring(this.href.lastIndexOf('/') + 1));
Add solution
Javascript
2021-09-20 03:54:03
clean facebook graphql response
cleanGraphQl(body) { // Response contains two json objects, we want the first one only const pos = body.lastIndexOf('{'); body = body.slice(0, pos - 1); try { return JSON.parse(body); } catch (e) { ...
Add solution
Javascript
2021-09-17 06:28:02
get filename from url js
var filename = location.pathname.substr(location.pathname.lastIndexOf("/")+1);
Add solution
Javascript
2021-09-07 02:25:02
js split last occurence
var lastIndex = src.lastIndexOf('.'); // Add the string before the last . // Return updated string, this will update the src attribute value return src.substr(0, lastIndex) + '-fx' + src.substr(lastIndex);
Add solution
Javascript
2021-09-06 14:42:01
angularjs left xx characters
angular.module('ng').filter('cut', function () { return function (value, wordwise, max, tail) { if (!value) return ''; max = parseInt(max, 10); if (!max) return value; if (value.length <= max) re...
Add solution
C#
2021-09-04 07:24:01
remove all text after string c#
string input = "text?here"; int index = input.LastIndexOf("?"); // Character to remove "?" if (index > 0) input = input.Substring(0, index); // This will remove all text after character ?
Add solution
‹
1
2
3
4
5
6
›
Best helpers
daily
weekly
monthly
for 3 months
Dee M
+5
Reader
+5
Sdqali
+5
Aerin
+5
Egil
+5
Benstone
+5
Mv Log
+5
Abdullahi saad
+5
WordLover
+5
Janet Walker
+5
Cledoux
+5
Mythio
+5
Ohio818
+5
Jay Cossey
+5
show more
This website uses cookies to make IQCode work for you. By using this site, you agree to our
cookie policy
Welcome Back!
Sign up to unlock all of IQCode features:
Test your skills and track progress
Engage in comprehensive interactive courses
Commit to daily skill-enhancing challenges
Solve practical, real-world issues
Share your insights and learnings
Sign in
E-mail
Password
Recover lost password
Log in
Or log in with
Not registered?
Sign up takes less than a minute
Create a Free Account
Sign up to unlock all of IQCode features:
Test your skills and track progress
Engage in comprehensive interactive courses
Commit to daily skill-enhancing challenges
Solve practical, real-world issues
Share your insights and learnings
Sign up
Email
Password
Sign up for free
Or sign up with
By signing up, you agree to the
Terms and Conditions
and
Privacy Policy
. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.